Nicolas Hoizey ha scritto:
Hi,
I'm currently using :contains() to find elements that contain some
string:
<http://docs.jquery.com/DOM/Traversing#contains.28_str_.29>
I would like now to find only elements that have a text content
exactly equal to the string I chose.
I didn't find any simple solution in the list archives or in any
documentation.
Thanks.
-Nicolas
Hi,
you can create a new selector to match text content with regular
expressions:
jQuery.expr[":"].containsRegEx =
"(a.textContent||a.innerText||'').match(eval('/'+m[3]+'/'))!=null";
and
$('a:containsRegEx(^my text$)')
It's a very simple code that does not escape the special regex characters.
I hope it helps
Ciao
Renato