我有这样的ul:
<ul class = "abc">
<li>
<span class = "X">
<a href="" title="alpha">alpha</a>
</span>
<span class = "Y">
</span>
<span class = "Z">
</span>
</li>
<li>
<span class = "X">
<a href="" title="beta">beta</a>
</span>
<span class = "Y">
</span>
<span class = "Z">
</span>
</li>
</ul>
在ul里面,类是abc我想选择具有title =“alpha”的li。我怎么能用jquery做到这一点?
答案 0 :(得分:5)
你去......
$('ul.abc').find('a[title=alpha]').closest('li');
答案 1 :(得分:4)
$("ul.abc a[title=alpha]").closest('li')
答案 2 :(得分:0)
试试这个:
$( 'ul.abc li' ).find( 'a[title=alpha]' );