How to find all unselected checkboxes?

后端 未结 2 1808
梦毁少年i
梦毁少年i 2021-02-19 22:26

In jQuery, how does one go about finding all the \'unchecked\' checked boxes.

$(\':checkbox:checked\');

appears to be me all checked boxes, but

2条回答
  •  渐次进展
    2021-02-19 23:04

    You use the :not selector, like so:

    $('input:checkbox:not(:checked)');
    

    Or the .not function, like so:

    $('input:checkbox').not(':checked');
    

    Also note that you should always put input before filters like :radio and :checkbox, as without that the selector are evaluated as *:checkbox which is a really slow selector.

提交回复
热议问题