views:

537

answers:

1

Hey guys, I've got an accordion which has the first panel opened on default by throwing in:

$("h4#open").trigger('click');

(which triggers the first panel to act as if the h4 link were clicked, and thus opened...)

But this seems to screw up the only way I can think of expanding / collapsing all the panels.

I have this code to expand / collapse:

$("a.ex-col").click(function(){
  $("div.accordion div").slideToggle("slow");
 return false;
});

When using this, all the panels toggle open and close except any panel that happens to be open (or closed) at the time.

How can I keep the default div opened on load, while also expanding / collapsing with the rest of them?

Thanks.

A: 

Why not just call slideToggle on loading the page instead of trying to simulate a click.

Mike Buckbee
I tried that but when expanding / collapsing, whichever one is open still toggles (thus closes while the others open and vice-versa). Even when I try .show (instead of toggle), I'm getting the same thing happening...
lorenzium
Instead of using slideToggle setup two functions: one to open all, one to close all.
Mike Buckbee