I'm looking for a way to replace all occurrences of "$" with "£" on my html pages using javascript.
How could you do this?
How could you do this?
Needs jQuery to work, add other elements to start if they contain a $ eg $('p,a,ul,li,tr,th,td,etc').each......$('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......
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.Can't you just use 'body' instead of listing each individual element to cover everything?
Of course there is anything you can do in jquery you can do in plain javascript, it'll just require more lines of code.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?