Possible Duplicate:
Find and Replace more than 1 word?
I want to use jQuery to replace all instances of specific words. For example, I want to replace "My Classes" to "My Levels" and "My Class" to "My Level". I also want to change "college" to "university"
You may try something like this:
var dictionary= {
"My Classes":"My Levels",
"My Class":"My Level",
"college":"university"
};
$("body *").each( function(){
for( var ptrn in dictionary){
$(this).text( $(this).text().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
}
});