replace text on html page with javascript



$('p,a,li,h1,h2,h3,h4,h5').each(function(){
var check = $(this).html()
$(this).html(check.replace(/$/gi,'£'))
});
Needs jQuery to work, add other elements to start if they contain a $ eg $('p,a,ul,li,tr,th,td,etc').each......
 
Can't you just use 'body' instead of listing each individual element to cover everything?
You could but then again you could accidentally change something important to the page structure ie. a $ symbol where it does not represent dollar. Try it on the firebug javascript console first to see if it messes with your page structure. If not then by all means use body instead of listing individual elements.

edit* Also I am just noting I have never before used something like this on an actual page and was just the first thing that came to mind when reading OP.
 
Also not sure if you understood what I want:

Depending on the a condition (user is from UK or US) I want to parse the whole text-copy of the page and replace all $ with £, using javascript. Is there a way without jQuery?
 
Also not sure if you understood what I want:

Depending on the a condition (user is from UK or US) I want to parse the whole text-copy of the page and replace all $ with £, using javascript. Is there a way without jQuery?
Of course there is anything you can do in jquery you can do in plain javascript, it'll just require more lines of code.

Why you no want use jquery?

Also Geo IP is well beyond the scope of changing a simple character on a page.
 
I have to do this since I determine the country of the visitor by Javascript. Only then I know if I want to show $ for US or £ for UK.

(Another reason is that I use caching and sometimes Google Website Optimizer, which rules server-side solutions out)