Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery无线电输入验证 答复1 答复2 答复3 答复4_Jquery - Fatal编程技术网

jquery无线电输入验证 答复1 答复2 答复3 答复4

jquery无线电输入验证 答复1 答复2 答复3 答复4,jquery,Jquery,如何做:如果勾选答案1,则在var测试中增加1分,如果其他答案中的一个被勾选,则增加0分 <form id="v-1"> <input type="radio" name="ot-1" value="o-1" /> answer1 <input type="radio" name="ot-1" value="o-2" /> answer2 <input type="radio" name="ot-

如何做:如果勾选答案1,则在
var测试中增加1分,如果其他答案中的一个被勾选,则增加0分


    <form id="v-1">
        <input type="radio" name="ot-1" value="o-1" /> answer1
        <input type="radio" name="ot-1" value="o-2" /> answer2
        <input type="radio" name="ot-1" value="o-3" /> answer3
        <input type="radio" name="ot-1" value="o-4" /> answer4
    </form>
答复1 答复2 答复3 答复4
JS:


测试=0;
$('input[name=ot-1]')。单击(函数(){
如果($(this.val()=“o-1”){
测试=测试+1;
}
});

答复1
答复2
答复3
答复4
JS:


测试=0;
$('input[name=ot-1]')。单击(函数(){
如果($(this.val()=“o-1”){
测试=测试+1;
}
});

在jquery中,您可以使用以下命令获取选中单选按钮的值

<script>

    test = 0;
    $('input[name=ot-1]').click(function(){
        if($(this).val()=="o-1"){
            test=test+1;
        }
    });
</script>
您可以在按钮事件中使用此选项:

var value = $("input[@name=ot-1]:checked").val();

在jquery中,您可以使用以下命令获取选中单选按钮的值

<script>

    test = 0;
    $('input[name=ot-1]').click(function(){
        if($(this).val()=="o-1"){
            test=test+1;
        }
    });
</script>
您可以在按钮事件中使用此选项:

var value = $("input[@name=ot-1]:checked").val();