[jQuery] Re: find text within the page

2009-02-03 Thread Eric Garside
Replace $(".keyword:contains('"+kw+"')") .each(function(){ With $(":contains('"+kw+"')").each(function(){ On Feb 3, 11:54 am, paulinstl wrote: > yeah.. this finds it by classname (.keyword) , I need to be able to > traverse all elements > > On Feb 3, 9:39 am, Eric Garside wrote: > > > Try: > >

[jQuery] Re: find text within the page

2009-02-03 Thread paulinstl
yeah.. this finds it by classname (.keyword) , I need to be able to traverse all elements On Feb 3, 9:39 am, Eric Garside wrote: > Try: > $(function(){ >    var keywords = [ ... ]; >    $.each(keywords, function(){ >       var kw = this, rx = new RegExp('/^ '+kw+' $/'); >       $(".keyword:conta

[jQuery] Re: find text within the page

2009-02-03 Thread Eric Garside
Try: $(function(){ var keywords = [ ... ]; $.each(keywords, function(){ var kw = this, rx = new RegExp('/^ '+kw+' $/'); $(".keyword:contains('"+kw+"')") .each(function(){ $(this).text($(this).text().replace(rx, ''+kw+'')); }); }); }); It's untested, but I th

[jQuery] Re: find text within the page

2009-02-03 Thread paulinstl
Rob, My problem is that I have no way of knowing where the keyword may appear. It might be tabular data () or in descriptive paragraph (). So if my keyword is RED, then... BEFORE the red fox AFTER the red fox I'll have an array of keywords as well. var arrayx["one", "two" "three"] On Feb

[jQuery] Re: find text within the page

2009-02-02 Thread RobG
On Feb 3, 8:01 am, paulinstl wrote: > I'm looking for a way to locate keywords to help the end user out. > > For instance, if I want to find the word "polar" then i'd like my > function to locate it, wrap it with a span, and assign it a function. > > so far I can locate using a content filter a

[jQuery] Re: find text within the page

2009-02-02 Thread kim3er
Could you do a string replace on the inner HTML? Something like: .replace(/keyword/, "keyword"); or use indexOf if you want to protect the case. Rich On Feb 2, 5:01 pm, paulinstl wrote: > I'm looking for a way to locate keywords to help the end user out. > > For instance, if I want to find the