December 2013
Intermediate to advanced
384 pages
9h 54m
English
if ($("#myCheckbox").is(":checked)){ $("#myCheckbox").removeAttr("checked"); else{ $("#myCheckbox").attr("checked"); }
Check box input elements have a boolean value based on whether the element is checked. You access the value by getting the value of the checked attribute. If the element is checked, then checked has a value such as true or "checked". Otherwise, the value will be undefined or false.
You can get and set the state of a check box element from JavaScript in the following manner:
domObj.checked = true; domObj.checked = false; var state = domObj.checked;
Determining whether an item is checked with jQuery is a bit different. ...
Read now
Unlock full access