Search w3schools.com:

SHARE THIS PAGE

DOM Document renameNode() Method

Document Object Reference Document Object

Example

Rename a P element:

var p=document.getElementsByTagName("P")[0];
document.renameNode(p,null,"h1");

Definition and Usage

The renameNode() method renames nodes of type Element and Attr.

Read more about the Element Node object in our Element Node object reference.

Read more about the Attr Node object in our Attr Node object reference.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The renameNode() method is not supported in any of the major browsers.


Syntax

document.renameNode(node,namespaceURI,nodename)

Parameters

Parameter Type Description
node Node object Required. The node object you want to rename
namespaceURI String Required, but can be set to null if you do not want to specify the namespace URI of the node
nodename String Required, the new nodename

Return Value

Type Description
Node object The renamed node

Technical Details

DOM Version Core Level 3


Document Object Reference Document Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]