[jQuery] Problem with chained commands

[jQuery] Problem with chained commands


Hi there,
please have a look at
http://clients.larsschulz.info/cc104_web/panel/quicklinks.html
I have h3 elements that are followed by divs that are toggled when the
h3 element is clicked...
        //quicklinks - slide up and down on click
        $("h3.trigger").click(function(){
            $(this).next(".sectiontext").slideToggle(150);
        });
Now I want to have certain divs visible when I load the page:
        //quicklinks - activate div
        $("h3.active").next(".sectiontext").slideToggle("fast");
I have the problem that the later misbehave, when I toggle them. The
action is actually reversed...
(click the example Test 1 post several times to see what I mean.
Can anybody help with this?
Thank you so much
Cheers
Lars
PS:
I tried the following code as a starting point:
        //quicklinks - switch the "Open" and "Close" state per click
        if($("h3.trigger").hasClass("active")) {
            $("h3.trigger").toggle(function(){
                $(this).addClass("active");
                }, function () {
                $(this).removeClass("active");
            });
        }
        else {
            $("h3.trigger").toggle(function(){
                $(this).removeClass("active");
                }, function() {
                $(this).addClass("active");
            });
        }




































    • Topic Participants

    • lars