我想要一个在 html 表中搜索的 javascript 或 jquery 函数,如果没有选择 radio ,则通知用户。我只有表 id,不知道 radio id。
最佳答案
在代码中,您可以将 table
替换为 #tableID
,以便代码仅针对该表运行
$(document).ready(function () {
if ($('table input[type=radio]:checked').length < 1) {
alert('No Radio Button Selected');
}
});
如果您想在表
上发出通知,请点击
$('table').click(function () {
if ($('table input[type=radio]:checked').length < 1) {
alert('No Radio Button Selected');
}
});
关于javascript - 循环 html 表并检查是否选择了 radio ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17972372/