I'm trying to iterate a set of textNodes and replacing some occurrences with an HTML element.
For example:
<span>some text<br>without html nodes</span>
Translates to
- Node1: Type Text
"some text" - Node2: Type Element:
<br> - Node3: Type Text:
"without html nodes"
How do I modify for example node 3 into:
- Node3: Type Text
"without" - Node4: Type Element
<span>html</html> - Node5: Type Text
"nodes"
So, basically I want to replace a substring of a textnode and convert it into an html node. Any ideas?
span.innerHTML = span.innerHTML.replace('html','<span>html</span>')