Hi Tyler,

One of the great things with jQuery is how quickly you'll find  
yourself giving other people advice...

What you're asking about is one of the first things I tried to do in  
jQuery, although your HTML structure is slightly different from mine  
(mine was simple nested unordered lists).

Anyway, the code you want is:

$('dt a').click(function(){
        $(this).parent().next().siblings('dd:visible').slideUp('slow');
        $(this).parent().next().slideToggle('slow');
        return false;
});


What this does is:

The $(this).parent().next() bit locates the <dd> element connected to  
the clicked link; and therefore its dd siblings are all the other dd  
elements. So we close them if they're visible, and then toggle the  
one we clicked.


Seb


On 24 Feb 2007, at 13:38, TE Gossman wrote:

> hi all jquery newbie here,
>
>    I'm working on a jquery accordion menu here:
> http://70.133.226.219/dwtIndex.htm
> It's the button menu on the left.
> It's written just using John R's DL demo from the screencast tutorial,
> with only one change that nothing is open initially.
>
> I can't figure out how to make the button's toggle when clicked,
> rather than if they are open, close and open again.
> I've seen some code hints but can't quite figure out exactly how to
> add those to the existing code.
> Thanks for any help.
>
> Another great idea that I think would receive some attention is if
> somebody could code up something like this:
> http://www.presidentielles.net/
>
>  The accordion panels cycle in the main content area on the left, on a
> timer like an automated slideshow. This one seems to be written using
> moo.fx. Takes just a few seconds before they begin the slideUp on the
> timer. Cool...
>
> If there a forum/message board anywhere dedicated to jquery?
> I think it makes more sense than a mailing list (said to the fans of
> the mailing list). :)
> The magazine idea was kind of a dud, great concept but there's only
> ever been one excellent edition, a magazine is usually put out
> regularly, a bit of a dissapointment :(
>
> Anyways thanks to everyone for all of their contributions to  
> everything jQuery!
> tyler
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to