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>
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>
Share
Improve this question
edited Dec 18, 2013 at 11:07
BenMorel
36.5k51 gold badges205 silver badges335 bronze badges
asked Feb 21, 2011 at 6:31
abc def foo barabc def foo bar
2,3886 gold badges30 silver badges42 bronze badges
1
- Looks like you forgot a closing quote – Andrew Marshall Commented Feb 21, 2011 at 6:34
8 Answers
Reset to default 6You can do this $('#foo').find('.status')
The selector would be:
$("#foo a.status");
Try this and read this:
$("#foo a.status")
Good luck!
This works.
$("#foo").find("a.status")
Try this:
$('div#foo a.status')
The docs are here
try with
$('div#foo > a.status')
it selects the anchors which are DIRECT children of div #foo
jQuery('#foo') //select elm with id foo
.find('a.status') //find anchor with class
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')