How to reset all checkboxes using jQuery?

Sometimes, we want to reset all checkboxes using jQuery.

In this article, we’ll look at how to reset all checkboxes using jQuery.

How to reset all checkboxes using jQuery?

To reset all checkboxes using jQuery, we can remove the checked attribute of all checkboxes with prop.

For instance, we write:

<input type='checkbox'>
<input type='checkbox'>
<input type='checkbox'>
<button>
  reset
</button>

to add some checkboxes and a reset button.

Then we write:

$('button').click(() => {
  $('input[type=checkbox]').prop('checked', false);
})

We select the button with $.

And we call click with a click event handler callback.

In the callback, we select all the checkboxes and call prop with 'checked' and false to uncheck all checkboxes.

Conclusion

To reset all checkboxes using jQuery, we can remove the checked attribute of all checkboxes with prop.