Or the underutilized second argument of jQuery, the context: $(":contains('whatever')", this)
-- Josh ----- Original Message ----- From: Glen Lipka To: jquery-en@googlegroups.com Sent: Thursday, December 13, 2007 7:49 AM Subject: [jQuery] Re: this:contains selector Something like this might work...not tested. $(this).is(":contains(matchingText)") Glen On Dec 12, 2007 4:55 PM, Van <[EMAIL PROTECTED]> wrote: The contains selector works fine with tags (a:contains()) etc. but doesn't seem to work with $(this). What is the best way to use contains with "this"?? here is my scenario: var matchingText = "Text2"; <ul class="list"> <li><a href="#">Text1</a></li> <li><a href="#">Text2</a></li> </ul> I want to see if the text in matchingText matches text in any of the anchor tags. My goal is to add a class to the anchor tag that has matching text and would like to use the ul.list selector to run through each of the n amount of anchor tags (descendants of ul class "list") I've tried selecting them in-line, or with a .each() loop and each time I cant seem to match using jQuery syntax... Thanks for the help.