jquery - Selecting element by a content text -
is there simple way (i mena selector) select element has specific 'content text'?.
for example, can have following situation
<div> <div class="a">text 1</div> <div class="a">text 2</div> <div class="a">text 3</div> </div>
we can like
$('div div.a').each(function() { if( ($this).text() == "text 1") { // } });
but there way can like:
$('div div.a[text="text 1"])
or
$('div div.a').someembededfunction('text 1')
?
use contains
$('div div.a:contains("text 1"))
something take account selector case sensitive. if need case insensitive version, you'll need implement own selector or override existing one.
Comments
Post a Comment