Return to Snippet

Revision: 55307
at February 1, 2012 23:27 by digitalclubb


Initial Code
var accordion = {
	init: function(){
		var $container = $('#accordion');
		$container.find('li:not(:first) .details').hide();
		$container.find('li:first').addClass('active');
		$container.on('click','li a',function(e){
			e.preventDefault();
			var $this = $(this).parents('li');
			if($this.hasClass('active')){
				if($('.details').is(':visible')) {
					$this.find('.details').slideUp();
				} else {
					$this.find('.details').slideDown();
				}
			} else {
				$container.find('li.active .details').slideUp();
				$container.find('li').removeClass('active');
				$this.addClass('active');
				$this.find('.details').slideDown();
			}
		});
	}
};

Initial URL

                                

Initial Description
Simple jQuery accordion function for jQuery version 1.7.1 and above.

Initial Title
jQuery Accordion (1.7.1)

Initial Tags
jquery

Initial Language
jQuery