Luv2Muff
asked on
jQuery - Replace text
Hi, I need a piece of jQuery that that scans the whole document and replaces all instances of "XXXX" with the text contained in the Meta Keywords tag, for example:
<meta name="keywords" content="YYYY" />
In this example all instances of "XXXX" will be replaced by "YYYY".
Thanks, Luv2.
<meta name="keywords" content="YYYY" />
In this example all instances of "XXXX" will be replaced by "YYYY".
Thanks, Luv2.
ASKER
Hi,
I am using a a CMS and cannot give the body a class, is there a way round this.
Also I do not want to replace the text with "YYYY", I just used that as an an example. I need to replace XXX with the text contained withing the Keywords Meta Tag:
<meta name="keywords" content="YYYY" />
I am using a a CMS and cannot give the body a class, is there a way round this.
Also I do not want to replace the text with "YYYY", I just used that as an an example. I need to replace XXX with the text contained withing the Keywords Meta Tag:
<meta name="keywords" content="YYYY" />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect thank you!!
Also trying to change the page title:
$(this).attr("title").repl ace(/XXXX/ ig, keywords_seo));
This does not work, can you tell me what would?
Thanks again.
Also trying to change the page title:
$(this).attr("title").repl
This does not work, can you tell me what would?
Thanks again.
Are you doing this for the search engines? To the best of my knowledge search engines will not see these. I may be wrong but I wouldn't spend too much time looking at jquery to do the job... you'd be better off looking at php.
var el = $('.BodyClass');
el.html(el.html().replace(
where BodyClass will be a class set on the body of the page