<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title></Head><Body><Div><bID= "OldNode">Javascript</b>is a very common technique for adding dynamic effects to a Web page.</Div><ahref= "Javascript:replacemessage ()">Change Bold to Italic</a><Scripttype= "Text/javascript">functionReplacemessage () {varOldNode=document.getElementById ("OldNode"); //extracting old elements;varNewNode=Document.createelement ("I");//create a new node;newnode.innerhtml=oldnode.innerhtml;//The old OldNode content assigned to the new NewNode, otherwise newnode is no content, but simply changed a property, the B into I, show is empty;OldNode.parentNode.replaceChild (newnode,oldnode);//implements the substitution of a child node (object) and returns a reference to the substituted object;} </Script></Body></HTML>
JavaScript replaces ELEMENT nodes