Avoiding child elements, such as <style> and <script>, to be replaced inside the target elements is necessary; otherwise, it would simply keep them from executing. For example,
<p id="tester">
<style scoped>span { color: red; }</style>
<span>Hello,</span>
people in red.
</p>
<script>
findAndReplaceDOMText(
/red/g,
document.getElementById('tester'),
'em'
);
</script>
Would outputs,
<p id="tester">
<style scoped>span { color: <em>red</em>; }</style>
<span>Hello,</span>
people in <em>red</em>.
</p>
Tried editing the function, but just not able to make it right. Hoping this could be solved.
Avoiding child elements, such as
<style>and<script>, to be replaced inside the target elements is necessary; otherwise, it would simply keep them from executing. For example,Would outputs,
Tried editing the function, but just not able to make it right. Hoping this could be solved.