I'm trying to find the following node within a page:
我正在尝试在页面中找到以下节点:
<span class="dotted">Admin</span>
I've tried the following jQuery selectors, but neither seem to work in selecting the node:
我尝试了以下jQuery选择器,但似乎都没有选择节点:
$(".dotted span:contains('Admin')").css("color","red");
$("span:contains('Admin') .dotted").css("color","red");
What am I doing wrong?
我究竟做错了什么?
1 个解决方案
#1
32
This selector should do what you want.
这个选择器应该做你想要的。
$("span.dotted:contains('Admin')")
Remember you can chain Tag names with IDs and classes. Example
请记住,您可以使用ID和类链标记标记名称。例
$("span#yourID")
OR
$("span.yourclass")
OR a mixture of the two
或两者的混合物
$("span#yourID.yourClass")
#1
32
This selector should do what you want.
这个选择器应该做你想要的。
$("span.dotted:contains('Admin')")
Remember you can chain Tag names with IDs and classes. Example
请记住,您可以使用ID和类链标记标记名称。例
$("span#yourID")
OR
$("span.yourclass")
OR a mixture of the two
或两者的混合物
$("span#yourID.yourClass")