/** * Mechbunny Tabs */ (function($){ $.fn.mbTabs = function() { $(this).each(function() { var $t = $(this); // multiple instance check if($t.is('.mb-tabs')) return false; $t.addClass('mb-tabs'); // jQuery objects var $tabsList = $t.find('.tabs-list li.tab a'); var $tabsContent = $t.find('.tabs-content'); // first tab active $tabsList.eq(0).closest('li').addClass('active'); $tabsContent.find($tabsList.eq(0).attr('href')).show().siblings().hide(); $tabsList.on('click', function(e){ e.preventDefault(); var $t = $(this); $t.closest('li').addClass('active').siblings().removeClass('active') $tabsContent.find($t.attr('href')).show().siblings().hide(); }); }); return this; } })(jQuery)