I have a string that is, <some text>
I'm trying to highlight the "te" in it, using replace function
InnerHTML = innerHTML.replace(some_Regex_Pattern['te'], '<span style='background-color:#FFFB00'>$&</span>');
The string I obtain is,
<some <span class='highlight' style='background-color:#FFFB00'>te</span>xt>
Now setting this to element.innerHTML, is considered as an HTML tag, causing problem.
In DOM I get the element as
<some <span class='highlight' style='background-color:#FFFB00'>te</span>xt></some>
I get the string in malformed form, how can I convert it to correct format, without making changes to the correct html tag i.e here?
How can I solve this issue,.. If it is not understandable, please comment,..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…