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?
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?
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;
Check it:
$('input[name=foo]').attr('checked', true);
Uncheck it:
$('input[name=foo]').attr('checked', false);
Adjust selector accordingly.
You just needs to remove the attribute checked
from the element.
$("#yourSelect").change(function () {
$("#yourCheckBox").removeAttr("checked");
});
I suppose the easiest method is to call $('theCheckbox').click()
You could also use $('theCheckbox').checked = false
, or $('theCheckbox').removeAttribute('checked')