3 ms·
this doesn't seem to work to well on a complex page like http://techcrunch.com/2010/07/29/apple-location/ http://techcrunch.com/2010/07/29/apple-location/ .
by jdavid 16y ago
this doesn't seem to work to well on a complex page like http://techcrunch.com/2010/07/29/apple-location/ http://techcrunch.com/2010/07/29/apple-location/ .
- byoung2 16y agoJust a few small changes fixes it: jQuery('div.entry').find(":contains('apple')").each(function() { var html = jQuery(this).html().replace(/apple/gi,"<span class='apple'>Apple</span>"); jQuery(this).html(html); }); I made the str.replace global and case-insensitive (/apple/gi), and changed $.children() to $.find() since on TC the content wasn't the direct descendant of a div. $.find() goes more than one level down. They also seem to be using jQuery.noConflict() so I changed the $ to jQuery. example: http://fillerspace.com/techcrunch.html http://fillerspace.com/techcrunch.html