首页 > 技术文章 > jQuery判断checkbox是否选中的3种方法

nerd 2015-12-23 09:47 原文

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

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

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

 

 function checkInfo(){
  $("input[name='org3.otherValues']").each(
   function(){
   if($(this).get(0).checked){
   return true;
    }
   });
  var org3_ids=$("#org3_ids").val();
  if(org3_ids!=''){
   return true;
  }
  
  alertMsg.warn("请选择接收人!");
  return false;
 }

推荐阅读