Created
August 8, 2013 21:24
-
-
Save psflannery/6188903 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/4886319/replace-text-in-html-page-with-jquery
See also - http://benalman.com/projects/jquery-replacetext-plugin/
Replace all occurrences of a word on a page
This file contains hidden or 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
var replaced = $("body").html().replace(/-1o9-2202/g,'The ALL new string'); | |
$("body").html(replaced); | |
//or, as a one liner | |
$("body").html($("body").html().replace(/12345-6789/g,'<b>abcde-fghi</b>')); | |
//replace every word | |
$("body").html($("p").html().replace(/[a-zA-Z0-9_]\w/g,'<b>oh hai!!!</b>')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment