jqueryHow do I uncheck a checkbox using jQuery?
To uncheck a checkbox using jQuery, you can use the prop() method. This method will set the property of the checkbox to false:
$('input[type="checkbox"]').prop('checked', false);
The code above will uncheck all checkboxes on the page. To uncheck a specific checkbox, you can use the attr() method, passing in the checked attribute and setting it to false:
$('#myCheckbox').attr('checked', false);
The code above will uncheck the checkbox with the id of myCheckbox.
Code explanation
$('input[type="checkbox"]')- This is a jQuery selector that selects all checkboxes on the page.prop('checked', false)- This is theprop()method that sets thecheckedproperty of the checkbox tofalse, thus unchecking it.$('#myCheckbox')- This is a jQuery selector that selects the checkbox with theidofmyCheckbox.attr('checked', false)- This is theattr()method that sets thecheckedattribute of the checkbox tofalse, thus unchecking it.
Here are some ## Helpful links
More of Jquery
- How do I use jQuery ZTree to create a hierarchical tree structure?
- How do I use jQuery to zip files?
- How can I use jQuery to check if an element is visible?
- How can I get the y position of an element using jQuery?
- How do I download a zip file using jQuery?
- How do I add a zoom feature to my website using jQuery?
- How do I use jQuery to zoom an image when it is clicked?
- How do I use jQuery to change the z-index of an element?
- How do I use jQuery to zoom in on an image?
- How do I use jQuery to zoom in or out on an element?
See more codes...