jQuery: The Write Less, Do More JavaScript Library

Re: How to find elements with an exact text content?

by Nicolas Hoizey :: Rate this Message:

| View in Thread


> You can try the powerful .filter() method with an anonymous  
> function as its argument:
>
> $('someElement').filter(function() {
>   return $(this).text() == 'Some text';
> });

It works well, but wouldn't it be very useful (and very "write less,  
do more") to have such a feature:

$('someElement:contains(^Some text$)')

Notice the '^' and '$' delimiters.


-Nicolas

--
Nicolas "Brush" HOIZEY
Clever Age   : http://www.clever-age.com/
Gastero Prod : http://www.gasteroprod.com/
Photos : http://www.flickr.com/gp/38608514@N00/M1c002


 « Return to Thread: How to find elements with an exact text content?