Making Accordions with the Tabs(jquery)
HTML coding
Our HTML layout is a bit different than in tabs. The accordion headers are positioned in front of the panes and everything is contained as a flat list inside a single root DIV element with an id of "accordion". We make the first tab visible "manually" on the HTML by setting the display:block property for the fist tab. We won't let the tabs do this automatically because we don't want to perform a slide effect when the page loads.
<div id="accordion"> <h2 class="current">First pane</h2> <div class="pane" style="display:block">... pane content ...</div> <h2>Second pane</h2> <div class="pane">... pane content ...</div> <h2>Third pane</h2> <div class="pane">... pane content ...</div> </div>
The styling is defined in a single documented CSS file:tabs-acc.css
JavaScript coding
This time we have no root element for our tabs so we have to explicitly tell the tool which elements work as tabs. This is specified in the tabs configuration option. The sliding effect suitable for accordions is supplied with the effect attribute. We unset the initialIndex property so that the first tab is not automatically opened when the page loads.
$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
You might also like
Tags
accordion accordion menu animation navigation animation navigation menu carousel checkbox inputs css3 css3 menu css3 navigation date picker dialog drag drop drop down menu drop down navigation menu elastic navigation form form validation gallery glide navigation horizontal navigation menu hover effect image gallery image hover image lightbox image scroller image slideshow multi-level navigation menus rating select dependent select list slide image slider menu stylish form table tabs text effect text scroller tooltips tree menu vertical navigation menu