美文网首页
jQuery判断checkbox是否选中的3种方法

jQuery判断checkbox是否选中的3种方法

作者: mingminy | 来源:发表于2017-12-01 17:24 被阅读0次

方法一:if($("#checkbox-id").get(0).checked) {//do something}

方法二:if($('#checkbox-id').is(':checked')) {//do something}

方法三:if($('#checkbox-id').attr('checked')) {//do something}

在jQuery1.6版本之后,取复选框有没有被选中,要用propif($('#checkbox-id').prop('checked'))

{

//do something

}  function checkInfo(){  $(

"input[name='org3.otherValues']").each(

function(){if($(this).get(0).checked){returntrue;

}

});varorg3_ids=$("#org3_ids").val();if(org3_ids!=''){returntrue;

}

alertMsg.warn("请选择接收人!");returnfalse;

}

相关文章

网友评论

      本文标题:jQuery判断checkbox是否选中的3种方法

      本文链接:https://www.haomeiwen.com/subject/stvwbxtx.html