Created
November 13, 2019 20:58
-
-
Save tomhodgins/9a308fe490501df96f8abaa42e17adce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replaceWord(element, target, replacement) { | |
var iterable = document.createNodeIterator(element, NodeFilter.SHOW_TEXT) | |
for (var node; node = iterable.nextNode();) { | |
node.data = node.data.replace(new RegExp(target, 'g'), replacement) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment