siblings() returns..siblings. Brothers/sisters, which aren't descendants. To get immediate children (sons/daughters), use children() To get descendants (sons/daughters, grandchildren, great- grandchildren, etc.) then use find()
btw, do you mean to have a space here: .slideToggl e(); ? On Apr 1, 10:04 am, Hector Virgen <djvir...@gmail.com> wrote: > $(this).siblings() only returns the immediate descendents of 'this'. > > Try using $(this).find() instead. > -Hector > > On Wed, Apr 1, 2009 at 9:28 AM, sinkingfish <sinkingf...@gmail.com> wrote: > > > Hi I trying to write a script which allows for easily hiding and revealing > > content by just specifying the correct class names. > > > The problem I'm having is that my current script will only toggle elements > > if the 'toggletarget' is a immediate sibling of the 'togglebutton'. My > > problem is that the 'togglebutton' may or may not be nested within div's, > > tables etc. > > > Is their a way to find all the children of an element? Am I missing > > something? > > > Ta > > > $(function(){ > > $("div.togglecontainer span.togglebutton").click(function() { > > $(this).siblings("div.toggletarget").slideToggle(); > > > //$(this).parent('div.togglecontainer').find('div.toggletarget').slideToggl > > e(); > > }).css('cursor', 'pointer'); > > $('div.toggletarget').hide(); > > }); > > -- > > View this message in context: > >http://www.nabble.com/Getting-all-children%2C-not-just-immediate-chil... > > Sent from the jQuery General Discussion mailing list archive at Nabble.com.