Let's say I have this portion of HTML document:
<div>hello world <span id="test"></span></div>
In straight JavaScript, I need to replace the span
with some HTML content contained in a string like '<span>other</span> yo <a href="www.google.ca">google</a>'
So the end result be like:
<div>hello world <span>other</span> yo <a href="www.google.ca">google</a></div>
The problem I'm facing is that the HTML string can contain any number of tags at its "root". So it is not a 1 to 1 replacement of tags.
I need to do that in straight JavaScript (no jQuery).
If anyone can help!
Thanks