Accordion - Expand/Collapse - but first panel is opened and screws it up

Posted by lorenzium on Stack Overflow See other posts from Stack Overflow or by lorenzium
Published on 2009-09-10T07:53:55Z Indexed on 2010/04/11 6:03 UTC
Read the original article Hit count: 397

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about accordion

Related posts about jQuery