02-May-2013 0 Comments
Boolean attributes such as checked only set the default or initial value. In the case of a checkbox, the checked attribute sets whether the checkbox should be checked when the page loads. Properties are what the browser uses to keep track of the current values. Normally, properties reflect their corresponding attributes (if they exist). This is not the case with boolean attributes. Boolean properties stay up to date when the user clicks a checkbox or selects an option in a select element. The corresponding boolean attributes do not. As was stated above, they are used by the browser only to store the initial value.
$(“:checkbox”).get(0).checked = true; // Is the same as $(":checkbox:first").prop(“checked”, true);In jQuery 1.6, setting checked with
$(“:checkbox”).attr(“checked”, true); would not check the checkbox because it was the property that needed to be set and all you were setting was the initial value.Reference jQuery 1.6 release