In release 1.6, we split the processing of DOM and DOM attribute attributes into separate methods. the new .prop () method sets or gets properties on the DOM elements and .removeProp () removes the properties. In the past, jQuery did not draw a clear line between properties and attributes. Typically, the DOM attributes represent the state of the DOM information as extracted from the document, such as the value attribute in the markup, the DOM properties represent the dynamic state of the document; for example, if the user clicks in the input element above and the types are def .prop("value") abcdef, but .attr("value") remains a.
In most cases, the browser considers the attribute value as the starting value for the property, but Boolean attributes such as checked or disabled have unusual semantics.
For example, consider the markup <input type="checkbox" checked> . the presence of a verified attribute means that the DOM .checked property is true, although the attribute does not matter. In the code above, the checked attribute value is an empty string (or undefined if no attribute was specified), but the checked property value is true .
Before jQuery 1.6, .attr("checked") returns the value of the Boolean ( true ) property, but as of jQuery 1.6 it returns the actual value of the attribute (empty string), which does not change when the user clicks on change its state.
There are several alternatives for checking the current state of a flag. The best and most executor should use the DOM property directly, as in this.checked event handler, when it refers to the element that was clicked. In code that uses jQuery 1.6 or later, the new $(this).prop("checked") method gets the same value as this.checked and is relatively fast. Finally, the expression $(this).is(":checked") works for all versions of jQuery.