Instead, you can use .children() , as Archer suggests, and you should . But the main problem is that you use .filter when you mean .find . Archer hints at this, but itβs important to understand that there was no problem with your design ("> a.thatOtherClass") , except for best practice.
filter does not cross the DOM tree; it removes elements from the current sequence at the same DOM level. So, when you wrote this:
var furtherSelection = selection.filter('> a.thatOtherClass');
You really said "elements that satisfy '#thisId > .thatClass' AND ALSO '> a.thatOtherClass' ." So you tested your average .thatClass elements when you were supposed to test your children. If you used find or children , this would work:
var furtherSelection = selection.find('> a.thatOtherClass');
See them in action on jsFiddle: http://jsfiddle.net/jmorgan123/S726f/
I point this out because the difference between .filter and .find very important, and your real problem was that you are confusing the two.
source share