Example: Replace an image with its alt text
This presumes that there is an element whose ID is "annoyingsmily"
.
var theImage, altText; theImage = document.getElementById('annoyingsmily'); if (theImage) { altText = document.createTextNode(theImage.alt); theImage.parentNode.replaceChild(altText, theImage); }
If you want to replace an element with a large chunk of HTML, you can construct the HTML as a string and then set the element's |