Return to Snippet

Revision: 6066
at April 24, 2008 11:42 by madmanlear


Initial Code
$.fn.expander = function() {
	$('.head', this).css("cursor","pointer");
	$('.head', this).siblings().hide();
    var expandedid = 'expanded';
    $('.head', this).bind('click', function() {
    	$('#' + expandedid + ' .head').siblings().hide('slow');
		var currentid = $(this).parent().attr('id');
		$('#' + expandedid).attr({id: ''});
		if(currentid !== expandedid) {
			$(this).siblings().show('slow');
			$(this).parent().attr({id: expandedid});
		}
		return false;
    })
}

Initial URL


Initial Description
Very basic accordion effect
Common structure would be an ID'd UL, and each LI to have a first child with the class of head
Shows and hides siblings of .head, attaches ID of expanded to current element

Initial Title
Basic Jquery Expander

Initial Tags


Initial Language
JavaScript