Possible Duplicate:
Jquery: Selection within a selection
first I select div element from some page, code like this:
var divs = $('div');
how can I select those div with someClass from divs. I try to use
divs.find('.someClass') or divs.find('div.someClass')
both of them can’t works.
what should I do if I want to achieve this task? By the way, I know I can use
$('div.someClass')
You can use the
.filter()method:This will reduce the matched set of elements to those matching the selector (in other words, those elements with the “someClass” class name).
Your current attempt with
.find()doesn’t work because it looks at descendant elements. You are trying to reduce the matched set, which consists of (effectively) siblings.