$(function() { var initIndex = 0; if(!(typeof(selectIndex) == "undefined")) { initIndex = selectIndex; } n=$('.kltwowrap a').size(); var wh=100*n+"%"; $('.kltwowrap').width(wh); var lt=(100/n/3); var lt_li=lt+"%"; $('.kltwowrap a').width(lt_li); $(".kltwowrap a").on('touchstart mousedown',function(e){ e.preventDefault() $(".kltwowrap .active").removeClass('active'); $(this).addClass('active'); tabsSwiper.slideTo($(this).index()); }); $(".kltwowrap a").click(function(e){ e.preventDefault(); }); window.onload=function(){ var pages = document.getElementById("swiper-pages"); var scale = window.screen.height / window.screen.width; pages.style.height = document.body.clientWidth * scale -$('.kltit').height()-$('.kltwo').height() - 20 + "px"; } var tabsSwiper = new Swiper(".swiper-container",{ initialSlide : initIndex, setWrapperSize :true, onSlideChangeStart: function(tabsSwiper){ $(".kltwowrap .active").removeClass('active'); var panelIndex = tabsSwiper.activeIndex; var $kltwowrapA = $(".kltwowrap a").eq(panelIndex); $kltwowrapA.addClass('active'); $kltwowrapA.parent().css("left",-parseInt(tabsSwiper.activeIndex/3)*tabsSwiper.width); query(panelIndex); } }); })