this).addClass(on).siblings().removeClass(on); let index = key = $(tabTit).children().index(this); $(tabCon).children().eq(index).fadeIn(200).siblings().fadeOut(0); if(speed >= base_num && playTimer !== null){ clearInterval(playTimer); } }); $(tabTit).children().mouseleave(function() { if(speed >= base_num && playTimer !== null){ playTimer = setInterval(auto_tabs,speed) } }); $(tabCon).mouseenter(function() { if(speed >= base_num && playTimer !== null){ clearInterval(playTimer); } }); $(tabCon).mouseleave(function() { if(speed >= base_num && playTimer !== null){ playTimer = setInterval(auto_tabs,speed) } }); }; function auto_tabs(tabTit='.Tabe',on='active',tabCon='.TabeCon'){ if(key >= 3){ key = 0; } $(tabTit).children().eq(key).addClass(on).siblings().removeClass(on); $(tabCon).children().eq(key).fadeIn(200).siblings().fadeOut(0); key++; }; tabs('.Tabe','active','.TabeCon');