$(function () { function tab2() { var leftArrow = $(".leftArrowTwo") var rightArrow = $(".rightArrowTwo") var allPelpol = $("#allPelpolTwo") var qh = $('#qhTwo') // var videohd=$('#videohd') // 目前选中项 var rightClick = 0 // 左右移动距离 var socerleft = 0 // 每次移动距离 var left = 1200 var right = -1200 var swiper = 0 var leftwidth = 0 var swiperleft = 221 var swiperright = -221 var swiperchelNum = document.getElementById('qhTwo').children.length // 子元素数量 var chelNum = document.getElementById('allPelpolTwo').children.length leftArrow.click(function () { rightClick -= 1 var lis1 = $("#qh div"); for (let j = 0; j < lis1.length; j++) { if (rightClick == j) { lis1.eq(rightClick).addClass('mrxzstyle') } else { lis1.eq(j).removeClass('mrxzstyle') } } if (rightClick < 0) { rightClick = swiperchelNum - 1 swiper = -2 * swiperleft leftwidth=swiper qh.css('transform', 'translateX('+leftwidth+'px)') qh.css('transition', 'all 1.5s') } if (rightClick < swiperchelNum - 2 && rightClick > 2) { leftwidth = leftwidth += swiperleft qh.css('transform', 'translateX('+leftwidth+'px)') qh.css('transition', 'all 1.5s') } // var jl = socerleft += left if (jl>0) { jl = (chelNum-1)*right socerleft=(chelNum-1)*right } allPelpol.css('transform', 'translateX('+jl+'px)') allPelpol.css('transition', 'all 1.5s') }) rightArrow.click(function () { rightClick += 1 var lis1 = $("#qhTwo div"); for (let j = 0; j < lis1.length; j++) { if (rightClick == j) { lis1.eq(rightClick).addClass('mrxzstyle') } else { lis1.eq(j).removeClass('mrxzstyle') } } if (rightClick > 3 && rightClick 3 && rightClick<swiperchelNum-1) { var leftwidth = swiper += swiperright qh.css('transform', 'translateX('+leftwidth+'px)') qh.css('transition', 'all 1.5s') } if (rightClick==swiperchelNum) { rightClick = 0 leftwidth = 0 swiper=0 qh.css('transform', 'translateX('+leftwidth+'px)') qh.css('transition', 'all 1.5s') lis1.eq(0).addClass('mrxzstyle') } // var jl = socerleft += right if (jl<(chelNum-1)*right) { jl = 0 socerleft=0 } allPelpol.css('transform', 'translateX('+jl+'px)') allPelpol.css('transition', 'all 1.5s') } var t = setInterval(intervaltwoId, 3000) var qhswiper = $("#qhTwo div"); for (let i = 0; i < qhswiper.length; i++) { qhswiper.eq(i).click(function() { var lis1 = $("#qhTwo div"); for (let j = 0; j < qhswiper.length; j++) { if (i == j) { lis1.eq(i).addClass('mrxzstyle') } else { lis1.eq(j).removeClass('mrxzstyle') } } var jl = right*i allPelpol.css('transform', 'translateX('+jl+'px)') allPelpol.css('transition', 'all 1.5s') }) qhswiper.eq(i).mouseover(function () { clearInterval(t); }) qhswiper.eq(i).mouseout(function () { t=setInterval(intervaltwoId,3000) }) } } tab2() }) // function tab2() { // setInterval(, 3000); // } // tab2()