<div class="codetitle"> <span><a style="CURSOR: pointer" data="65923" class="copybut" id="copybut65923" onclick="doCopy('code65923')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code65923"> <br><title></title> <br><script type="text/javascript"> <br>function createNode() { <br>var pNode = document.createElement('p'); <br>var tNode = document.createTextNode('Fireworks in Yangzhou in March' ); <br>pNode.appendChild(tNode); <br>document.body.appendChild(pNode); <br>} <br>function r() { <br>var pNode = document.createElement('p') ; <br>var tNode = document.createTextNode('The old friend Xici Yellow Crane Tower'); <br>pNode.appendChild(tNode); <br>//Get the node to be replaced<br>var reNode = document.getElementsByTagName ('p')[0]; <br>//This method is only applicable to IE browser<br>//reNode.replaceNode(pNode, reNode); <br>//Applicable to various browsers<br>reNode.parentNode.replaceChild(pNode, reNode); <br>} <br>function reNode() { <br>var oldNode = document.getElementsByTagName('p')[0]; <br>//oldNode.parentNode What is returned is the parent node of the p node, here is the body <br>//Then use the removeChild method of the body node to delete the oldNode node <br>oldNode.parentNode.removeChild(oldNode); <br>} <br>< /script> <br></head> <br><body> <br><input id="Button1" type="button" value="Create Node" onclick="createNode()"/> <br><input id="Button2" type="button" value="Replace node" onclick="r()" /> <br><input id="Button3" type="button" value= "Delete node" onclick="reNode()" /> <br></body> <br></html> <br> </div>