如何在单选按钮中创建条件? (在jQuery Ajax中)

I want to create the conditions in the radio button.

so I'm making a survey app with jquery ajax. every question has the option (radio button) and the button next to to the next question. without changing link

I want to create the conditions in the radio button. If select YES then it will go to the next question. If you select NO then the next question will pass 2

can help me please?

have you tried doing an attribute on your radio button like arnum that will track the n^th number of radio button.

<div arnum="3">
    <input type="radio" skipval="3"  value="yes">
    <input type="radio" skipval="1"  value="no">
</div>
<div  arnum="4">
<input type="radio"  value="something">
    <input type="radio" value="else">
</div>

then:

$('div[arnum] input[type=radio][skipval]').on('click',function(){
var skipval = parseInt($(this).attr('skipval'));
var arnum = parseInt($(this).parent().attr('arnum'));
arnum++;
for(;arnum<arnum+skipval;arnum++){
$('div[arnum='+arnum+']').attr('disable','disable');
}
$('div[arnum='+arnum+']').focus();

});

this code on click skips to the next question using skipval and disables everything in between.

y this:

  <input type="radio" name="test" value="1" />yes<br />
    <input type="radio" name="test" value="2" />no


    <div id="question2" style="display:none">
        <br />Question 2<br />
    </div>

<script>
        $('input[name=test]').change(function () {
            if ($(this).val() == 1) {
                $('#question2').show();
            } else {
                $('#question2').hide();

            }
        })
</script>