使用正则表达式的Jquery css选择器 [英] Jquery css selector using regular expressions
本文介绍了使用正则表达式的Jquery css选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 DYNAMICALLY 生成的导航div
I have a DYNAMICALLY generated Navigation div
<div id="WebPartWPQ9" >
<table class="xm-ptabarea">
<tbody>
<tr>
<td nowrap="" class="tab"><a href="/somelink.aspx">Overview</a></td>
<td nowrap="" class="tab"><a href="/anothersomelink.aspx">Financials</a></td>
<td nowrap="" class="tab"><a href="/somemorelink.aspx">Newsfeed</a></td>
</tr>
</tbody>
</table>
</div>
由于没有唯一ID ,所以使用jquery能够将事件附加到财务标签链接(可能使用正则表达式选择器)
Since there are no unique IDs, using jquery, i want to be able to attach an event to the "financial" tab link (using regular expressions selectors maybe?)
链接的值始终为财务
推荐答案
使用< a> =http://api.jquery.com/contains-selector/ =nofollow> :contains
selector :
It's super easy to select that <a>
element using the :contains
selector:
var $financialsLink = $('#WebPartWPQ9').find('td.tab > a:contains(Financials)');
这篇关于使用正则表达式的Jquery css选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文