Node Operation JavaScript DHTML







var pTag = document.createElement("p");
pTag.setAttribute("id","myP");
document.body.appendChild(pTag);
pTag.appendChild(document.createTextNode("This is a paragraph."));
var hyperLinkTag = document.createElement("a");
hyperLinkTag.setAttribute("id","myA");
hyperLinkTag.setAttribute("href","http://www.google.com/");
document.body.appendChild(hyperLinkTag);
hyperLinkTag.appendChild(document.createTextNode("Click Here"));
var existingp = document.getElementById("myP");
existingp.firstChild.nodeValue="This is the new text.";
var newanchor = document.getElementById("myA");
newanchor.setAttribute("href","http://www.microsoft.com/");