Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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验证表中的单选按钮_Jquery_Asp.net - Fatal编程技术网

如何使用jQuery验证表中的单选按钮

如何使用jQuery验证表中的单选按钮,jquery,asp.net,Jquery,Asp.net,我有一些在运行时创建的单选按钮,它们在一个表中。我如何使用jQuery检查其中一个是否被选中 谢谢你可以这样试试 $('#table tbody tr input[type=radio]').each(function(){ alert($(this).attr('checked')); }); 或 有很多方法可以做到这一点,例如,使用和遍历方法: $("table tr td input[name=something]:radio").each(function() {

我有一些在运行时创建的单选按钮,它们在一个表中。我如何使用jQuery检查其中一个是否被选中


谢谢你可以这样试试

 $('#table tbody tr input[type=radio]').each(function(){
     alert($(this).attr('checked'));
    });

有很多方法可以做到这一点,例如,使用和遍历方法:

$("table tr td input[name=something]:radio").each(function() {
    if($(this).is(":checked")) {
        $(this).closest("tr").css("border", "1px solid red");
    } else {
        // do something else
    }
});
或者你可以这样做

在单选按钮项上定义一个类,基本上客户端HTML应该看起来像

现在,在js代码中,只需在类上连接一个事件处理程序

$(".myrdo").bind("click",function(){if($(this).attr("checked")==true) {alert($(this).val);} });
上述命令只会提醒所选单选按钮的值

一般解决方案:

if ( $( 'input[type="radio"]', '#table' ).is( ':checked' ) ) {
    // validation passes
}

使用表格进行布局,不是吗<代码>:)单选按钮是否属于同一单选按钮组?