jQuery Replace All Text On Page
Share
Simple jQuery code snippet to replace all the text on the place with any given string. Could be useful for changing company names based on dynamic variables which may change.
Important: don’t forget that the replace() function returns a value and does not do a live update on the page. In order to do this you simply assign the page element with the result of the .replace().
//ie to replace all dots on page with hyphens
var replace_str = $('body').html().replace(/./g,'-');
$('body').html(replace_str);
//if that doesn't work try this
var strNewString = $('body').html().replace(/./g,'---');
$('body').html(strNewString);