I want to insert html in the current range (W3C range).
I think I need to use the insertNode method. And it works great with text.
Example:
var node = document.createTextNode("some text"); range.insertNode(node);
The problem is that I want to insert html (maybe something like "<h1> test </ h1> some text"). And no createHTMLNode ().
I tried using createElement ('div'), giving it id and html as innerHTML, and then trying to replace it with nodeValue after inserting it, but it gives me DOM errors.
Is there a way to do this without getting the extra html element around the html that I want to insert?
Martin
source share