且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重置页面上的所有复选框而不循环

更新时间:2023-12-03 09:15:16

您可以使用单个选择器查找所有选中的复选框,并从中删除已检查属性。 jQuery将通过循环在内部执行此操作,但您不必自己编写循环:

You can use a single selector to find all the checked checkboxes, and remove the 'checked' attribute from them. jQuery will do this internally by looping, but you will not have to write a loop yourself:

 $(':checkbox:checked').removeAttr('checked');

参见 :复选框 :已选中 选择器。

See the :checkbox and :checked selectors.