accordion Using Jquery UI

Customize the header icons with the icons option, which accepts classes for the header’s default and selected (open) state. Use any class from the UI CSS framework, or create custom classes with background images.

Make the selected elements Accordion widgets. Semantic requirements:

The markup of your accordion container needs pairs of headers and content panels. By default, the header elements are anchors, assuming the following structure:

<div id="accordion">
    <a href="#">First header</a>
    <div>First content</div>
    <a href="#">Second header</a>
    <div>Second content</div>
</div>

If you use a different element for the header, specify the header-option with an appropriate selector, eg. header: ‘h3’. The content element must be always next to its header.

If you have links inside the accordion content and use a-elements as headers, add a class to them and use that as the header, eg. header: ‘a.header’.

Use activate(Number) to change the active content programmatically.

NOTE: If you want multiple sections open at once, don’t use an accordion

An accordion doesn’t allow more than one content panel to be open at the same time, and it takes a lot of effort to do that. If you are looking for a widget that allows more than one content panel to be open, don’t use this. Usually it can be written with a few lines of jQuery instead, something like this:

jQuery(document).ready(function(){
	$('.accordion .head').click(function() {
		$(this).next().toggle();
		return false;
	}).next().hide();
});

Or animated:

jQuery(document).ready(function(){
	$('.accordion .head').click(function() {
		$(this).next().toggle('slow');
		return false;
	}).next().hide();
});

The jQuery UI Accordion plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain.

If a deeper level of customization is needed, there are widget-specific classes referenced within the ui.accordion.css stylesheet that can be modified. These classes are highlighed in bold below.

Sample markup with jQuery UI CSS Framework classes

<div class=”ui-accordion ui-widget ui-helper-reset”>
<h3 class=”ui-accordion-header ui-helper-reset ui-state-active ui-corner-top”>
<span class=”ui-icon ui-icon-triangle-1-s”/>
<a href=”#”>Section 1</a>
</h3>
<div class=”ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active“>
Section 1 content
</div>
<h3 class=”ui-accordion-header ui-helper-reset ui-state-default ui-corner-all”>
<span class=”ui-icon ui-icon-triangle-1-e”/>
<a href=”#”>Section 2</a>
</h3>
<div class=”ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom”>
Section 2 content
</div>
<h3 class=”ui-accordion-header ui-helper-reset ui-state-default ui-corner-all”>
<span class=”ui-icon ui-icon-triangle-1-e”/>
<a href=”#”>Section 3</a>
</h3>
<div class=”ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom”>
Section 3 content
</div>
</div>
Note: This is a sample of markup generated by the accordion plugin, not markup you should use to create a accordion. The only markup needed for that is
<div>
<h3><a href=”#”>Section 1</a></h3>
<div>
Section 1 content
</div>
<h3><a href=”#”>Section 2</a></h3>
<div>
Section 2 content
</div>
<h3><a href=”#”>Section 3</a></h3>
<div>
Section 3 content
</div>
</div>.

3 comments

  1. It never ceases to surprise me how, with a bit of extra browsing online, you can uncover some of the most unique articles. It’s annoying that more pages like this, arent listed at the top when I look with google online, I have added you to my favorites, I also have a friend, that will really enjoy this blog, so ill send them, a link to your website, as well. I am certain they will really like it.

  2. Pretty impressive article. I just stumbled upon your site and wanted to say that I have really enjoyed reading your opinions. Any way I’ll be subscribing to your feed and I hope you post again soon.

  3. I were searching for this for an hour on google. THen after I gave up I searched on yahoo after this and you came up on first page!

Leave a Reply to weight loss raw diet Cancel reply

Your email address will not be published. Required fields are marked *

*

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha

WP-SpamFree by Pole Position Marketing

Please note: JavaScript is required to post comments.