name (W3C DOM Core property)
| Version | Depr. | Static | Read-only |
|---|---|---|---|
| DOM1 | No | No | Yes |
| IE5.5+ | FF3+ | SA3+ | OP9+ |
|---|---|---|---|
| Full | Buggy | Full | Buggy |
Example
var attrs = document.documentElement.attributes;
for(var i=0; i<attrs.length; i++)
{
var attrname = attrs[i].name;
}
In the example above we create a reference to the documentElement attributes collection, then we iterate through the
collection numerically and retrieve the name of
each individual attribute.
Description
The name of an Attr. This is the name part of a
name="value" pair.
For a namespaced
attribute, the name property returns a
qualified name1.
This property is read-only.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Full | Full | Full | Full | Full | Buggy | Buggy | Buggy | Full | Buggy | Buggy |
In Opera
9.0 in HTML mode2 the name of an attribute is
often returned in uppercase; a consistent pattern for when this
does/doesn't occur could not be established, but appears to be related to
whether that attribute has already been referred to in lower case (in
which case its name is returned in lowercase, otherwise
uppercase).
In Internet Explorer 5.5 in HTML it's
not possible to retrieve attribute nodes; however in situations where
these objects are available their name always
returns correctly, hence this property is considered fully
supported.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.




