innerHTML not rendering after replace
问题 I am trying to get certain words to highlight in a page. To accomplish this, I want to find all text nodes and replace only the specific word with a span that will highlight it. The code appears to search and find the words in the text nodes properly, but the replace is not working. I get this: <span style="background-color: #FBC300;">foo</span> And I want to get this: foo (with a highlighted background) function toRegExp(text) { return new RegExp(text, 'g'); } function toSpan(text) { return