...

View Full Version : Jquery Accordion Multiple Openings



pennella
10-11-2010, 09:59 PM
Hey guys.
having some more trouble on my accordion again.
I want to (on click) open only one chapter and then on the next click on the same button close that chapter. My problem is...when i click on chapter one...chapter two opens as well and ergo closes when i click chapter 1 again.

See it here:
www.truthv2.com/religion/bts.html

pennella
10-11-2010, 10:25 PM
Heres the link for the tutorial. I couldn't find why i had an error

http://www.stemkoski.com/stupid-simple-jquery-accordion-menu/

SB65
10-12-2010, 10:00 AM
Your best approach would be to first remove those line breaks you have between .accordionButton and .accordionContent, and instead add the following to your css:


.accordionButton{clear:left;margin-bottom:2em}
.accordionContent{clear:left}


You then have each .accordionButton and .accordionContent adjacent to each other in the code and hence you can amend your javascript to:


$(document).ready(function() {

//ACCORDION BUTTON ACTION
$('div.accordionButton').click(function() {
$(this).next('.accordionContent').slideToggle('normal');
});

//HIDE THE DIVS ON PAGE LOAD
$("div.accordionContent").hide();

});


So here we apply the slide to the next element (next()) from the clicked element (this()), making sure it's the .accordionContent.

pennella
10-13-2010, 12:00 AM
Thank you for your help.
I did those changes and now the accordion doesn't open at all.

Your thoughts?
http://www.truthv2.com/religion/bts.html

SB65
10-13-2010, 08:12 AM
You haven't removed the line breaks as I suggested - this is necessary so that the .accordionContent is the next item within the html to the .accordionButton.

pennella
10-13-2010, 01:53 PM
Truly a genius. Thank you once again for your help with this project.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum