Reputation: 13620
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?
Upvotes: 6
Views: 32751
Reputation: 3778
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;
Upvotes: 21
Reputation:
You just needs to remove the attribute checked
from the element.
$("#yourSelect").change(function () {
$("#yourCheckBox").removeAttr("checked");
});
Upvotes: 1
Reputation: 17638
plese see this post
also note that in jquery 1.6 you should use
$(".mycheckbox").prop("checked", true/false)
Upvotes: 2
Reputation: 22619
Check it:
$('input[name=foo]').attr('checked', true);
Uncheck it:
$('input[name=foo]').attr('checked', false);
Adjust selector accordingly.
Upvotes: 1
Reputation: 4901
I suppose the easiest method is to call $('theCheckbox').click()
You could also use $('theCheckbox').checked = false
, or $('theCheckbox').removeAttribute('checked')
Upvotes: -1