|
Post by Schubaltz on Jun 12, 2007 23:28:52 GMT -5
Description: Kind of a reverse appendChild. This function wraps an element around another.
Syntax: containNode(wrapper node, node)
function containNode(a, b) { b.parentNode.replaceChild( a.cloneNode(true).appendChild(b.cloneNode(true)).parentNode, b ); }
Example: <html> <body><div>Hello <b>world</b></div></body> </html>
containNode(document.createElement("blockquote"), document.body.firstChild) // wrap BLOCKQUOTE element around DIV
|
|