You are here: Reference > JavaScript > client-side > attribute handling

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)
8
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)
9
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
9
Returns the attribute node with the specified namespace and name from the current element.
getAttributeNS
9
Returns the value of the attribute with the specified namespace and name from the current element.
getExpression
9
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)
9
Returns the attribute node with the specified namespace and name from the current attributes collection.
hasAttribute
8
Returns whether the current element has an attribute with the specified name or not.
hasAttributeNS
9
Returns whether the current element has an attribute with the specified namespace and name or not.
hasAttributes
8
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
9
Removes the attribute with the specified namespace and name from the current element.
removeBehavior
Removes the specified behavior from the current element.
removeExpression
9
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)
9
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
9
Adds the specified attribute node to the current element.
setAttributeNS
9
Adds an attribute with the specified namespace, name and value to the current element.
setExpression
9
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)
9
Adds the specified attribute node to the current attributes collection.
User Contributed Comments

Post Content

Post Content