I want to replace all instances of 'foo' with 'foo2' using jQuery.
I've come across the following answer in other threads:
$("p").text(function(index, text) {
return text.replace('foo', 'foo2');
});
But that only changes the first instance of foo in any given paragraph:
Fiddle: https://jsfiddle.net/sj76uh5r/