A
A
Alexey2010-12-21 12:08:50
JavaScript
Alexey, 2010-12-21 12:08:50

How to select an element by full text match (jQuery)?

Have a DOM tree

<elem1><br>
  <child1> 1 </child1><br>
  <child2> 2 </child2><br>
  <child3> 1 1 </child3><br>
</elem1><br>

I need to select a child element that contains exactly "1" (but not "1 1"), so the .contains() operation doesn't work.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
konfuze, 2010-12-21
@konfuze

$.each and comparing desired string with .text()?

S
sedictor, 2010-12-21
@sedictor

api.jquery.com/contains-selector/ - probably, sometimes you need to get into the API Reference

K
Konstantin Kitmanov, 2010-12-21
@k12th

Write your own filter, it's easy: anton.shevchuk.name/javascript/jquery-for-beginners-filter-extend/
However, this will not be fast anyway, it would be better to use classes or some other attributes to find what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question