HTML DOM renameNode() 方法

Document 对象参考手册 Document 对象

实例

重新命名 p 元素:

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

定义和用法

renameNode() 方法重命名已有的元素节点或属性节点。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

目前没有主流浏览器支持 renameNode() 方法。


语法

document.renameNode(node,namespaceURI,nodename)

参数

参数类型 描述
nodeNode 对象必需,需要重命名的节点对象。
namespaceURIString必需,如果你不想指定可以设置 namespace URI的节点可以设置为 null 。
nodenameString必需,新的节点名。

返回值

类型 描述
Node 对象重命名节点

技术细节

DOM 版本Core Level 3 Document 对象


Document 对象参考手册 Document 对象