It should be .parents $(this).parents('div.popup:first')
On Feb 28, 9:05 pm, "Rick Faircloth" <r...@whitestonemedia.com> wrote: > Assuming that the cancel link has an id of 'cancel': > > How about: > > $(document).ready(function() { > > $('#cancel').click(function() { > $(this).parent('div.popup:first') > }); > > }); > > Not sure what you want to do with the parent div > when you locate it... > > untested, buy may work... > > hth, > > Rick > > -----Original Message----- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > > Behalf Of riotbrrd > Sent: Saturday, February 28, 2009 11:47 PM > To: jQuery (English) > Subject: [jQuery] How to find a parent > > I have a bunch of Divs with class ".popup". Each div is different in what it > contains; some are simple, some are pretty complex, containing tables, other > divs, etc.. > > If I have a link, for example,"Cancel", within that Div, and the only thing > that I know about Cancel is that 1) it has a parent div.popup somewhere up > the tree (no idea how many levels), and 2) if I go backwards up the tree > from Cancel, the first div.popup I encounter will be the right one, how can > I go about finding the right parent div.popup? I'd like to just attach a > handler that starts with "this" (meaning the Cancel link) and finds the > correct div.popup up the tree. > > Hope this is question is clear. Thanks! > -Kim