Firstly, thank you for posting this. I was just dusting off an old Javascript collapse code, and this looks way more elegant than the code I was using.
I want to use an image/button to show and hide the content, so I would just replace the "H2" with "img" in this bit of code I'm assuming correct?
// Assign onclick events to the accordion item category image
for ( var i = 0; i < accordionItems.length; i++ ) {
var img = getFirstChildWithTagName( accordionItems[i], 'img' );
img.onclick = toggleItem;
}
And then if I want all accordianItem content to hide itself by default, I would just remove this portion of the javascript right?
// Hide all accordion item bodies except the first
for ( var i = 1; i < accordionItems.length; i++ ) {
accordionItems[i].className = 'accordionItem hide';
}
I'm sure I'll figure this out through trial and error, but confirmation is always nice =)
Thanks again
[Edited by myexpression on 11-Oct-10 16:46]