我想使用以下脚本更改页面上的一些单词。我不知道如何解决它......有人可以帮忙吗?
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;
});