$(document).ready(function() { var $wrapper = $('.sy-tab-wrapper'), $allTabs = $wrapper.find('.sy-tab-content > div'), $tabMenu = $wrapper.find('.sy-tab-menu li'), $line = $('
').appendTo($tabMenu); $allTabs.not(':first-of-type').hide(); $tabMenu.filter(':first-of-type').find(':first').width('100%') $tabMenu.each(function(i) { $(this).attr('data-tab', 'tab'+i); }); $allTabs.each(function(i) { $(this).attr('data-tab', 'tab'+i); }); $tabMenu.on('click', function() { var dataTab = $(this).data('tab'), $getWrapper = $(this).closest($wrapper); $getWrapper.find($tabMenu).removeClass('sy-active'); $(this).addClass('sy-active'); $getWrapper.find($allTabs).hide(); $getWrapper.find($allTabs).filter('[data-tab='+dataTab+']').show(); }); });//end ready