$(this).parents('.A').find('.findme');
On Nov 28, 10:35 pm, Keith Grennan <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I find myself doing this a lot, and thinking there must be a more > elegant way... > > <div class="A"> > <div class="A1"> > <a href="" id="clickme">Click me</a> > </div> > <div class="A2"> > <div class="findme"></div> > </div> > </div> > > $("#clickme").bind('click', function() { > > var container = $(this).parents('.A'); > var findme = $('.findme', container); > > }); > > Is there a way to make those two traversals into a single jQuery line, > without knowing what the structure is beneath '.A', only that there is > a '.findme' in there somewhere? > > $(this).parents('.A').children('.findme'); doesn't work because > children just looks at the immediate children. > > A traversal function like .descendants() (to children() as parents() > is to parent()) would be cool. > > Thanks for any suggestions.