find all unchecked checkbox in jquery

后端 未结 8 1222
情歌与酒
情歌与酒 2020-12-04 06:27

I have a list of checkboxes:




        
相关标签:
8条回答
  • 2020-12-04 07:22

    You can use like this :

    $(":checkbox:not(:checked)")
    
    0 讨论(0)
  • 2020-12-04 07:24
    $("input[type='checkbox']:not(:checked):not('\#chkAll\')").map(function () { 
       var a = ""; 
       if (this.name != "chkAll") { 
          a = this.name + "|off"; 
       } 
       return a; 
    }).get().join();
    

    This will retrieve all unchecked checkboxes and exclude the "chkAll" checkbox that I use to check|uncheck all checkboxes. Since I want to know what value I'm passing to the database I set these to off, since the checkboxes give me a value of on.

    //looking for unchecked checkboxes, but don’t include the checkbox all that checks or unchecks all checkboxes
    //.map - Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
    
    //.get - Retrieve the DOM elements matched by the jQuery object.
    //.join - (javascript) joins the elements of an array into a string, and returns the string.The elements will be separated by a specified separator. The default separator is comma (,).
    
    0 讨论(0)
提交回复
热议问题