[Before]
<div id="foo">
<img src="image.png" />
</div>
[After]
<div id="foo">
<a href="bar.html"><img src="image.png" /></a>
</div>
In article <Xn********************@194.109.133.242>, Evertjan.
<ex**************@interxnl.netwrote:
var foo = document.getElementById('foo');
foo.innerHTML = '<a href="bar.html">' + foo.innerHTML + '</a>';
Thanks for the super-fast response!
I am looking for an explaination of how to do this using
document.createElement just to get an understanding of how to wrap
node(s).
I can assume this much...
var div = document.getElementById("foo");
var anchor = document.createElement("a");
anchor.setAttribute("href", [dynamically assigned] );
anchor.setAttribute("title","Click here to ...");
// now I need to wrap the anchor node that was just created around
// div#foo. How make this worky? ;)
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche