What is the jQuery selector for selecting anchor elements with a particular class in a particular div
24,958
Solution 1
You can do this $('#foo').find('.status')
Solution 2
The selector would be:
$("#foo a.status");
Solution 3
Try this and read this:
$("#foo a.status")
Good luck!
Solution 4
This works.
$("#foo").find("a.status")
Author by
abc def foo bar
Updated on December 19, 2020Comments
-
abc def foo bar over 3 years
I have some code like this and I want to select every
<a>
tag with the classstatus
in the divfoo
<div id="foo"> ... <a class = "status"> ... </a> ... </div>
-
Alex about 13 yearsA note: This will select only the anchors with a class of
status
that are direct children of the div with an id offoo
. This may be what the OP was after, I just wanted to provide clarity here. -
Mauricio about 13 years@Alex thanx, I'll add that to the answer
-
Gonzalo Larralde about 12 yearshasClass returns boolean, not the elements that actually has the class. Anyway, the link is great.