HTML DOM replaceChild method
Examples
Replaces a child node to another:
document.getElementById("myList").replaceChild( newnode , oldnode );
Remove Money:
- Coffee
- Tea
- Milk
After removal:
- Water
- Tea
- Milk
try it"
Definition and Usage
replaceChild () method can be a child node is replaced with another.
New nodes can be text already exists, or your newly created.
Browser Support
All major browsers support replaceChild method
grammar
node.replaceChild(newnode,oldnode)
parameter
参数 | 类型 | 描述 |
---|---|---|
newnode | Node 对象 | 必须。你要插入的节点对象。 |
oldnode | Node object | 必须。你要移除的节点对象。 |
return value
类型 | 描述 |
---|---|
Node object | 替换的节点 |
technical details
DOM version | Core Level 1 Node Object |
---|