getNamedItem (W3C DOM Core method)
| Version | Depr. | Static |
|---|---|---|
| DOM1 | No | No |
| IE6+ | FF1.5+ | SA1.3+ | OP9+ |
|---|---|---|---|
| Full | Full | Full | Full |
- Returns
Node
Example
var attr = document.documentElement.attributes.getNamedItem('xmlns');
The example above retrieves a node called xmlns, from
the attributes collection of the documentElement. If it exists in the collection,
the attr variable will be a reference to that node,
otherwise it will be null.
That example could also be written using the array syntax:
var attr = document.documentElement.attributes['xmlns'];
However in some cases an implementation might not support that syntax (for
example Safari 2 in HTML, and Internet Explorer in XML, do not support the
shortcut key syntax for accessing members of the attributes collection).
Description
Get a node with the specified
name from a NamedNodeMap.
Return value
A node (of any type) with the
specified name; or null if it doesn't identify a node
in the map.
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 |
| Partial | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
Apart from IE 5.5, this method is better supported for accessing
members of a NamedNodeMap than the array
syntax, therefore the use of this method should be preferred.
Internet Explorer 5.5 in HTML doesn't implement this method (it returns undefined).
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.