Return to Snippet

Revision: 24974
at March 17, 2010 05:20 by errkk


Initial Code
(function($){ $.fn.tabisha = function(o){
	var o = $.extend({
		activeClass: 'active',
		items: '.item',
		clickThings: 'ul.nav li a'
	}, o);
	
	// Loop through each in case there are multiple selected
	return $(this).each(function(){
		var that = $(this),
			item = $(that).find(o.items),
			clickThings = $(that).find(o.clickThings);
		
		// no point doing anything if here is only 1 item
		if (2 > item.length) return;
		
		// Hide all but the first
		item.hide().eq(0).show();
		clickThings.eq(0).parent().addClass(o.activeClass);
		
		// Loop through each clickthings
		clickThings.each(function(i){
			
			// Apply click event to the clicky item
			$(this).click(function(){
				// Sets active state
				$(this).parent().siblings().removeClass(o.activeClass);
				$(this).parent().addClass(o.activeClass);
				
				//that.hide().show();
				item.hide().show();
				//clickThings.hide().show();
				
				// Show the right content
				item.hide().eq(i).show();
				
				return false;
			});
		});
		
	});

}})(jQuery);

Initial URL


Initial Description


Initial Title
Tabbed feature for jQuery

Initial Tags
jquery

Initial Language
JavaScript