开发者

google chrome, jquery statement, need help

开发者 https://www.devze.com 2023-03-05 11:03 出处:网络
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:

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

精彩评论

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