I have a checkbox that is always checked, but base on user input elsewhere in my form (I have a onChange="functionName"
on a select box) I would like to uncheck it.
How do I do that?
Once the checkbox is selected, we are calling prop() function as prop( "checked", true ) to check the checkbox and prop( "checked", false ) to uncheck the checkbox.
To uncheck the checkbox: $("#checkboxid"). removeAttr("checked");
You can do it like below. Add another click event for checkbox under #checkboxlist , if a checkbox is unchecked then uncheck . selectall .
Answer: Use the jQuery prop() method You can use the jQuery prop() method to check or uncheck a checkbox dynamically such as on click of button or an hyperlink etc. The prop() method require jQuery 1.6 and above.
does it need to be done with jQuery ? what about JavaScript please try this:
Check: document.getElementById("ckBox").checked = true;
UnCheck: document.getElementById("ckBox").checked = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With