/

HTML / CSS / JavaScript Tutorial

JavaScript Document own method: renameNode()

[this page | pdf | back links]

In theory, the renameNode() method (when applied to the document object of the JavaScript DOM) renames the specified node.

 

In practice, renameNode() does not currently seem to be supported by major browsers, so it is likely to be more robust to create the new node as desired, add it to the document in the appropriate place and then delete the old node.

 

It has the following syntax with the following parameters. It returns a Node object.

 

document.renameNode(node, namespaceURI, newtagname)

 

Parameter

Required / Optional

Description

node

Required

Node object representing node to be renamed (i.e. given a new node type)

namespaceURI

Required

Namespace URI of node, but can be set to null if you don’t want to specify it

newnodename

Required

New tag name

 


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


Desktop view | Switch to Mobile