问题
I have some code like this and I want to select every <a> tag with the class status in the div foo
<div id="foo">
...
<a class = "status"> ... </a>
...
</div>
回答1:
You can do this $('#foo').find('.status')
回答2:
The selector would be:
$("#foo a.status");
回答3:
Try this and read this:
$("#foo a.status")
Good luck!
回答4:
This works.
$("#foo").find("a.status")
回答5:
Try this:
$('div#foo a.status')
The docs are here
回答6:
try with
$('div#foo > a.status')
it selects the anchors which are DIRECT children of div #foo
回答7:
jQuery('#foo') //select elm with id foo
.find('a.status') //find anchor with class
回答8:
There is no such thing as a "jQuery selector", what you mean is :
either CSS selector :
In that case the answer is div#foo a.status or also div#foo > a.status (depending if there are intermediate containers)
or jQuery functions :
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')
来源:https://stackoverflow.com/questions/5062989/what-is-the-jquery-selector-for-selecting-anchor-elements-with-a-particular-clas