Finding all checkboxes are checked in jQuery

后端 未结 2 1102
囚心锁ツ
囚心锁ツ 2020-12-14 07:51

I have a collection of checkboxes

 
 
 <         


        
2条回答
  •  时光说笑
    2020-12-14 08:07

    I think there would be a good feature in jquery an are function:

    jQuery.fn.are = function(selector) {
    return !!selector && this.filter(selector).length == this.length;
    };
    

    Usage:

    if($('input.paid[type=checkbox]').are(':checked'))
    

    Example:

    http://jsfiddle.net/9s2vA/

    I have found this function at http://api.jquery.com/is/ written by Tgr , when I was checking if this exists.

提交回复
热议问题