使用JQ判断单选框或多选框是否选中

版权声明:本文为博主原创文章,未经博主允许不得转载。转载请在文章开头添加出处: https://blog.csdn.net/weixin_38676276/article/details/86594428
if($("input[type='radio'][selector1]:checked").length===0){//这里可以根据你的需要判断length的长度,然后做相应的事情
    alert('msg');
}
if($("input[type='checkbox']:checked").length===0){
    alert('msg');
}

$("input[type='radio'][selector1][selector2]:checked")表示已选中的单选按钮。其中selector1,2表示选择器,根据你的需要填写,type='radio'就是一个选择器,选择器可以写多个。

猜你喜欢

转载自blog.csdn.net/weixin_38676276/article/details/86594428