jQuery text attribute selector

Posted by Shagglez on Stack Overflow See other posts from Stack Overflow or by Shagglez
Published on 2010-06-17T10:32:14Z Indexed on 2010/06/17 10:43 UTC
Read the original article Hit count: 230

I am trying to use the text attribute as a selector, but I can't quite grasp the behaviour, would really appreciate if someone could explain. For example given <span class="span_class"><a class="a_class">text</a></span>, $('a.a_class').text() gives "text" as expected. However $('a.a_class[text]') wouldn't match any elements, and neither would $('span.span_class > a.a_class[text]'), but $('span.span_class* > a.a_class[text]') would (although not in IE). The only workaround I can think of for IE, is loop through all anchors contained in a span, use .text() on each and match it against a certain criteria, but it seems slower than using in-built selectors. Anyone have better ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about internet-explorer