
replaceChild
The replaceChild() method replaces one child node on the current element with another.
Syntax
element.replaceChild(newChild, oldChild)
Parameters
newChild is a node.
oldChild is the existing child node to be replaced.
Example
<html>
<head>
<script language="javascript">
function init()
{
d1 = document.getElementById("top");
d2 = document.getElementById("in");
d_new = document.createElement("p");
d1.replaceChild(d_new, d2);
alert(d1.childNodes[1].nodeName)
}
</script>
</head>
<body onload="init()">
<div id="top" align="left">
<div id="in">in
</div>
</body>
</html>
|
Notes
extra information
Specification
replaceChild
Netscape Communications
http://developer.netscape.com
|