当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - clearing input fields changing slides and on button input

问题描述:

I am having multiple slides which will hold multiple forms. I want to clear out the radio input fields when I change the slide or do a submit. Seems to me my approach isnt working. Any suggestion?

here is the code I have so far

<style>

.yesDisplay, .noDisplay, .yesSub{

display:none;

}

.myc { display:none; }

</style>

<script type='text/javascript'>

$(function () {

var $myc= $('.myc');

var cp = 0;

$('#pauseB').click (function () {

$myc.hide().eq(cp++).show();

if (cp == $myc.length) cp = 0;

});

// check the radio input for Yes

function checkYes(){

if($('.yes').attr('checked')){

$('.yesDisplay').show();

}else{

$('.yesDisplay').hide();

}

}

// check the radio input for No

function checkNo(){

if($('.no').attr('checked')){

$('yesDisplay').show();

}else{

$('.noDisplay').hide();

}

}

$('.cases').change(function(){

checkYes();

checkNo();

});

});

</script>

<div id="pauseB">Pause</div>

<div id="one" class="myc">1<br>

<form class="cases">

<input type="radio" class="yes" name="first"/>yes

<input type="radio" class="no" name="first"/>no

</form>

<div class="display">

<div class="yesDisplay">Secondary Question

<form class="cases">

<input type="radio" class="yes1" name="first"/>yes

<input type="radio" class="no1" name="first"/>no

</form>

</div>

<div class="noDisplay"><input type="button" value="test"/></div>

<div class="yesSub">1.1</div>

</div>

</div>

<div id="two" class="myc">2<br>

<form class="cases">

<input type="radio" class="yes" name="first"/>yes

<input type="radio" class="no" name="first"/>no

</form>

<div class="display">

<div class="yesDisplay">Secondary Question

<form class="cases">

<input type="radio" class="yes1" name="first"/>yes

<input type="radio" class="no1" name="first"/>no

</form>

</div>

<div class="noDisplay">no</div>

<div class="yesSub">1.1</div>

</div>

</div>

<div id="three" class="myc">3</div>

分享给朋友:
您可能感兴趣的文章:
随机阅读: