Attribute handling objects, properties and methods in JavaScript
Related objects:
| Object | Support | Description | |||||
|---|---|---|---|---|---|---|---|
| attribute | Represents an attribute of an element in an HTML or XML document. | ||||||
| attributes | Represents a collection of attribute nodes that belong to an element. |
Related properties:
| Property | Support | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| length (attributes) |
Returns an integer that specifies the number of attributes in the current collection. | |||||||||||
| name (attribute) |
Returns the name of the current attribute. | |||||||||||
| ownerElement (attribute) |
|
Returns the element object that contains the current attribute. | ||||||||||
| specified (attribute) |
Retrieves a Boolean value that indicates whether an attribute is specified. | |||||||||||
| value (attribute) |
Sets or returns the value of the current attribute. |
Related methods:
| Method | Support | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| clearAttributes | Clears all attributes from the current element, except the id, name, style, value and event attributes. | |||||||||||
| createAttribute (document, XMLDocument) |
Creates a new attribute node with the specified name. | |||||||||||
| createAttributeNS (document, XMLDocument) |
|
Creates a new attribute node with the specified namespace and name. | ||||||||||
| getAttribute | Returns the value of the attribute with the specified name from the current element. | |||||||||||
| getAttributeNode | Returns the attribute node with the specified name from the current element. | |||||||||||
| getAttributeNodeNS |
|
Returns the attribute node with the specified namespace and name from the current element. | ||||||||||
| getAttributeNS |
|
Returns the value of the attribute with the specified namespace and name from the current element. | ||||||||||
| getExpression |
|
Returns the dynamic expression for the specified DHTML property on the current element. | ||||||||||
| getNamedItem (attributes) |
Returns the attribute node with the specified name from the current attributes collection. | |||||||||||
| getNamedItemNS (attributes) |
|
Returns the attribute node with the specified namespace and name from the current attributes collection. | ||||||||||
| hasAttribute |
|
Returns whether the current element has an attribute with the specified name or not. | ||||||||||
| hasAttributeNS |
|
Returns whether the current element has an attribute with the specified namespace and name or not. | ||||||||||
| hasAttributes |
|
Returns whether the current element has any attributes specified or not. | ||||||||||
| item (attributes) |
Returns an element from the current collection by index. | |||||||||||
| mergeAttributes | Copies all attributes and its values from the specified element to the current element. | |||||||||||
| removeAttribute | Removes the attribute with the specified name from the current element. | |||||||||||
| removeAttributeNode | Removes the specified attribute node from the current element. | |||||||||||
| removeAttributeNS |
|
Removes the attribute with the specified namespace and name from the current element. | ||||||||||
| removeBehavior | Removes the specified behavior from the current element. | |||||||||||
| removeExpression |
|
Removes the dynamic expression from the specified DHTML property on the current element. | ||||||||||
| removeNamedItem (attributes) |
Removes the attribute with the specified name from the current attributes collection and returns the removed attribute node. | |||||||||||
| removeNamedItemNS (attributes) |
|
Removes the attribute with the specified namespace and name from the current attributes collection and returns the removed attribute node. | ||||||||||
| setAttribute | Adds an attribute with the specified name and value to the current element. | |||||||||||
| setAttributeNode | Adds the specified attribute node to the current element. | |||||||||||
| setAttributeNodeNS |
|
Adds the specified attribute node to the current element. | ||||||||||
| setAttributeNS |
|
Adds an attribute with the specified namespace, name and value to the current element. | ||||||||||
| setExpression |
|
Sets a dynamic expression for the specified DHTML property on the current element. | ||||||||||
| setNamedItem (attributes) |
Adds the specified attribute node to the current attributes collection. | |||||||||||
| setNamedItemNS (attributes) |
|
Adds the specified attribute node to the current attributes collection. |
User Contributed Comments
