I want to change some words on a page with the below script. I m not sure how to fix it … can anybody help?
http://jsfiddle.net/cip691/yUMS7/
var dict = {
"not": " NOT ",
"is not": " IS NOT ",
"like": " likeeee ",
"Like": "lllike",
"job": "JOB"
},
terms = [],
term;
for (term in dict) { terms.push(term);
var search = new RegExp('\\b(' + terms.join('|') + ')\\b', 'g');
};
// now for every text node:
textNode.data = textNode.data.replace(search, function(full, match) {
return dict[match] || match;
});
you should define
textNodelike in this example
link example