Reset all checkboxes on page without looping

 

Questions


I was wondering if it was possible to reset all the checkboxes (mark them unchecked) on the page without looping using jQuery?

 

 

————————————————-

Answer

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.

javascript,jquery

Facebook Comments

Post a comment