Or: $(document).ready(function(){ $("a.show").click(function () { $(this).siblings("div.hidden").slideToggle("fast"); }); });
Which will hopefully protect against the markup changing. Or better still, go up to the parent, then back in to find the right div.hidden: $(document).ready(function(){ $("a.show").click(function () { $("div.hidden", $ (this).parent()).slideToggle("fast"); }); }); Adrian On Oct 5, 4:06 pm, diego valobra <[EMAIL PROTECTED]> wrote: > Hi, another example.. > > $(document).ready(function(){ > > $('.hidden').hide(0) // just if you want all items closed at the beginning > > $('a.show').click(function () { > > $('.hidden').slideUp('fast') // just if you want a kind of accordion > > $(this).next('div').slideToggle('fast') // it takes just the next div > :) > > }); > > > }); > > here is a demo http://www.pirolab.it/piro_09/slide_up.html > > Diego > > --- Dom 5/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> ha scritto: > Da: [EMAIL PROTECTED] <[EMAIL PROTECTED]> > Oggetto: [jQuery] Only show div's within parent. > A: "jQuery (English)" <jquery-en@googlegroups.com> > Data: Domenica 5 ottobre 2008, 14:32 > > This is my first time with jQuery! > > I have a list like this: > <ul id="results"> > <li> > <a href="#" class="show">some text</a> > <div class="hidden">some text</div> > </li> > <li> > <a href="#" class="show">some text</a> > <div class="hidden">some text</div> > </li> > <li> > <a href="#" class="show">some text</a> > <div class="hidden">some text</div> > </li> > </ul> > > And a script like this: > $(document).ready(function(){ > $("a.show").click(function () { > $("div.hidden").slideToggle("fast"); > }); > > }); > > Now when a press one of the links with the class "show" it does show > every div with the class "hidden". But I only want to show the child > div of the link "show". Not all of them. > > Is that possible and how? > > Scopri il blog di Yahoo! Mail: > Trucchi, novità e la tua opinione.http://www.ymailblogit.com/blog