<span>aa</span>
<span>bb</span>
<span>cc</span>
<span>dd</span>
......
如上代碼,span的個數不固定,現在只知道“cc”這個值,如何用這個值,選中其所在的span?
我想到的是這樣$("span[text='cc']"),可惜行不通,直接js能實現也可以~求大神指教~~
:contains選擇器
<span>aa</span>
<span>bb</span>
<span>cc</span>
<span>ccdd</span>
<span>dd</span>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
console.log( $("span:contains('cc')[innerHTML='cc']"))
</script>
</html>