开发者

google chrome, jquery statement, need help

I'm trying to replace every occurrence of the text "basketball" on any page using a Google Chrome extension with jQuery. So in my content script, I have the code:

$('body').html($('body').htm开发者_运维问答l().replace('basketball', 'test'));

but on most pages, the site just doesn't load or looks very messed up. Any ideas?


I am not to sure about the google chrome extenstion but there are many ways to search and replace text. http://jsfiddle.net/zxpgx/ is an example of this.

$("*").each(function () { if ($(this).children().length == 0) { $(this).text($(this).text().replace('basketball','test')); } });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜