/

HTML / CSS / JavaScript Tutorial

JavaScript DOM NamedNodeMap method: setNamedItem()

[this page | pdf | back links]

The setNamedItem() method (when applied to NamedNodeMap objects in the JavaScript DOM) adds / sets a specified node (specified by name). If the node already existed then the old node will be replaced. If it didn’t previously exist then it will be addNote: if you are setting an element attribute then you can use the element.setAttribute() instead.

 

It has the following syntax with the following parameters. It returns a node object representing the replaced object (if any), or null if no replacement occurred.

 

namednodemap.setNamedItem(node)

 

Parameter

Required / Optional

Description

node

Required

Node object to be added or to replace the relevant old node

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile