Wanted to add an example to funky-future's answer as I kept getting this error:
Uncaught TypeError: element.childNodes is not iterable
use like this:
replaceInText(document.body,"search term","replacement");
it didn't work for me with jQuery selectors.