Wednesday, September 12, 2012

How to set checkbox in JQuery or Javascript?

By javascript directly:
document.getElementById('checkboxID').checked = true;
document.getElementById('checkboxID').checked = false;
Problem:
In early version jQuery, the behavior in IE, FF and Chrome  are different.

Or use prop function in jQuery 1.6+
$(".myCheckbox").prop("checked", true);
$(".myCheckbox").prop("checked", false);