diff --git a/entries/attr.xml b/entries/attr.xml index 03baf91c..d74cf22c 100644 --- a/entries/attr.xml +++ b/entries/attr.xml @@ -26,7 +26,7 @@
The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr()
method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop()
method provides a way to explicitly retrieve property values, while .attr()
retrieves attributes.
For example, selectedIndex
, tagName
, nodeName
, nodeType
, ownerDocument
, defaultChecked
, and defaultSelected
should be retrieved and set with the .prop()
method. Prior to jQuery 1.6, these properties were retrievable with the .attr()
method, but this was not within the scope of attr
. These do not have corresponding attributes and are only properties.
Concerning boolean attributes, consider a DOM element defined by the HTML markup <input type="checkbox" checked="checked" />
, and assume it is in a JavaScript variable named elem
:
Concerning boolean attributes, consider a DOM element defined by the HTML markup <input type="checkbox" checked="" />
, and assume it is in a JavaScript variable named elem
:
@@ -44,7 +44,14 @@ |
elem.getAttribute( "checked" )
|
- "checked" (String) Initial state of the checkbox; does not change |
+ "" (String) Initial state of the checkbox; does not change |
+
---|---|---|---|
+ $( elem ).attr( "checked" )
+ (4.0+)
+ |
+ "" (String) Initial state of the checkbox; does not change |
||
@@ -131,6 +138,7 @@ The title of the emphasis is:
null , the specified attribute will be removed (as in .removeAttr() ).null , the specified attribute will be removed (as in .removeAttr() ). Non-ARIA attributes can also be removed by passing false .When setting multiple attributes, the quotes around attribute names are optional. +Removing an attribute+To remove an attribute, either call
+
Note: Because ARIA attributes frequently associate behavior with "false" values that differs from attribute absence, passing WARNING: When setting the 'class' attribute, you must always use quotes! Note: Attempting to change the |