I have a Selector in a Selector. I want the inner Selector to select only those elements, that are also selected by the outer Selector.
This is what my naiveté came up with:
$('.some-class').hover(function() {
$( this + '.another-class');
})
Put differently, I want the elements with with another-class AND which are children of the element that is hovering. How do I do that?
Use the
children()method.This method falls under the traversal category, which allows you to select ancestors, descendants, siblings etc all from the current element.