[英]What is the jQuery selector for selecting anchor elements with a particular class in a particular div
I have some code like this and I want to select every <a>
tag with the class status
in the div foo
我有一些像这样的代码,我想在div foo
选择每个具有类status
<a>
标签
<div id="foo">
...
<a class = "status"> ... </a>
...
</div>
你可以这样做$('#foo').find('.status')
选择器将是:
$("#foo a.status");
这有效。
$("#foo").find("a.status")
There is no such thing as a "jQuery selector", what you mean is : 没有“jQuery选择器”这样的东西,你的意思是:
either CSS selector : 要么CSS选择器 :
In that case the answer is div#foo a.status
or also div#foo > a.status
(depending if there are intermediate containers) 在这种情况下,答案是div#foo a.status
或div#foo > a.status
(取决于是否有中间容器)
or jQuery functions : 或者jQuery函数 :
In that case there are several ways to do it : 在这种情况下,有几种方法可以做到:
$('div#foo a.status')
$('div#foo > a.status')
$('div#foo').find('a.status')
$('div#foo').children('a.status')
try with 尝试
$('div#foo > a.status')
it selects the anchors which are DIRECT children of div #foo 它选择了div #foo的DIRECT子节点的锚点
jQuery('#foo') //select elm with id foo
.find('a.status') //find anchor with class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.