jQuery: how can I select only the checkboxes that are visible and checked?

后端 未结 3 1867
野趣味
野趣味 2021-02-15 11:37

I\'m trying to check whether or not all the visible check boxes in a certain series are checked and i thought of just counting those that are visible and those that are visible

3条回答
  •  鱼传尺愫
    2021-02-15 12:22

    You could do something like this:

    jsfiddle

    jQuery:

    $('input').each(function() {
    
        // If input is visible and checked...
        if ( $(this).is(':visible') && $(this).prop('checked') ) {
    
            $(this).wrap('
    '); } });

    HTML:

    
    
    
    
    
    
    

    CSS:

    div { float: left; background: green; }
    div input { display: block !important; }
    

提交回复
热议问题