Ok, I've messed around quite a bit, and here is a Fiddle Demo
I messed around with your code a little bit, I hope you don't mind :)
Basically I removed the tables and such, so it would fit the structure of the accordion better.
Basically what you need is blocks of questions. Each block has 2 children, an h3
element (could be another if you want) and a div
element.
I gave those blocks a class, and initialized them as such:
$( ".questionBlock" ).accordion({collapsible: true, active: false });
This way they start collapsed. Expand each and you can see they each have their own height based on their own content.
Let me know if it's not clear yet.
EDIT: Ok I've adjusted it better. This is the initialization:
$( "#questions" ).accordion({collapsible: true, active: false, autoHeight: false});
Also, there is no need for the code blocks questionBlock
anymore. All you need is the questions
as id, and then follow up with the <h3>
& div
combos. I updated the fiddler demo.
Update: Add heightStyle: "content"
to your initialization so you'll have:
$( ".questions").accordion({collapsible: true, active: false, autoHeight: false, heightStyle: "content"});
And your fiddle is good to go.