Answers:
我使用的一种可靠方法是:
if($("#checkSurfaceEnvironment-1").prop('checked') == true){
    //do something
}如果要遍历选中的元素,请使用父元素
$("#parentId").find("checkbox").each(function(){
    if ($(this).prop('checked')==true){ 
        //do something
    }
});更多信息:
这很好用,因为所有复选框都有一个选中的属性,用于存储复选框的实际状态。如果希望,您可以检查页面并尝试选中和取消选中复选框,那么您会注意到属性“ checked”(如果存在)将保持不变。此属性仅代表复选框的初始状态,而不代表当前状态。当前状态存储在该复选框的dom元素选中的属性中。
请参见HTML中的属性和属性
checked = true
                    您也可以使用jQuery .not()方法或:not()选择器:
if ($('#checkSurfaceEnvironment').not(':checked').length) {
    // do stuff for not selected
}从jQuery API文档中:not() 选择器:
与将复杂的选择器或变量推入:not()选择器过滤器相比,.not() 方法最终将为您提供更具可读性的选择。在大多数情况下,这是一个更好的选择。
if ( $("#checkSurfaceEnvironment-1").is(":checked") && $("#checkSurfaceEnvironment-2").not(":checked") )我一直在寻找像avijendr建议的更直接的实现。
我在使用他/她的语法时遇到了一些麻烦,但是我可以使用它:
if ($('.user-forms input[id*="chkPrint"]:not(:checked)').length > 0)就我而言,我有一个表的一类user-forms,而我检查,如果任何有串的复选框checkPrint他们id都听之任之。
这里有这个问题的摘要。
$(function(){
   $("#buttoncheck").click(function(){
        if($('[type="checkbox"]').is(":checked")){
            $('.checkboxStatus').html("Congratulations! "+$('[type="checkbox"]:checked').length+" checkbox checked");
        }else{
            $('.checkboxStatus').html("Sorry! Checkbox is not checked");
         }
         return false;
   })
    
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
  <p>
    <label>
      <input type="checkbox" name="CheckboxGroup1" value="checkbox" id="CheckboxGroup1_0">
      Checkbox</label>
    <br>
    <label>
      <input type="checkbox" name="CheckboxGroup1_" value="checkbox" id="CheckboxGroup1_1">
      Checkbox</label>
    <br>
  </p>
  <p>
    <input type="reset" value="Reset">
    <input type="submit" id="buttoncheck" value="Check">
  </p>
  <p class="checkboxStatus"></p>
</form>简单,易于检查或不受检查的状况
<input type="checkbox" id="ev-click" name="" value="" >
<script>
    $( "#ev-click" ).click(function() {
        if(this.checked){
            alert('checked');
        }
        if(!this.checked){
            alert('Unchecked');
        }
    });
</script>试试这个
if ($("#checkSurfaceEnvironment-1:checked").length>0) {
    //your code in case of NOT checked
}在上述代码中,按ID选择元素,(#checkSurfaceEnvironment-1)然后按过滤器过滤掉其检查状态(:checked)。
它将返回选中元素对象的数组。如果数组中存在任何对象,则满足条件。
这是给出的最简单的方法
 <script type="text/javascript">
        $(document).ready(function () {
            $("#chk_selall").change("click", function () {
                if (this.checked)
                {
                    //do something
                }
                if (!this.checked)
                {
                    //do something
                }
            });
        });
    </script>我用这个为我工作!
$("checkbox selector").click(function() {
    if($(this).prop('checked')==true){
       do what you need!
    }
});$("#chkFruits_0,#chkFruits_1,#chkFruits_2,#chkFruits_3,#chkFruits_4").change(function () {
        var item = $("#chkFruits_0,#chkFruits_1,#chkFruits_2,#chkFruits_3,#chkFruits_4");
    if (item.is(":checked")==true) {
        //execute your code here
    }
    else if (item.is(":not(:checked)"))
    {
        //execute your code here
    }
});
||不&&检查或者检查。&&检查是否都选中。