.pcA{display: block!important;} .phA{display: none!important;} #CKTA>div{position: relative} @media screen and (max-width:800px) { .pcA{display: none!important;} .phA{display: block!important;} } < > // = 800 && screen.width >= screen.height) { $(".box>.ph_bf").remove() }else { $(".box>.pc_bf").remove() } }); var prevIndex = 0; var curIndex = 0; $("#next").click(function() { //.is(":animated"):正在执行动画返回true,没在执行动画返回false if ($(".box>.LBnr").eq(curIndex).is(":animated")) { return; } if (curIndex >= $(".box>.LBnr").length - 1) { curIndex = 0; } else { curIndex++ } tab(); prevIndex = curIndex; }); $("#prev").click(function() { if ($(".box>.LBnr").eq(curIndex).is(":animated")) { return; } if (curIndex <= 0) { curIndex = $(".box>.LBnr").length - 1; } else { curIndex--; } tab(); prevIndex = curIndex; }); $(".nav li").click(function() { curIndex = $(this).index(); if (curIndex == prevIndex) { return; } tab(); prevIndex = curIndex; }); //左边按钮:向右边滑动; function tab() { //切大图; if (curIndex == 0 && prevIndex == 2) { //边界2,当前在最后一张,点击next //向左滑动:前一张向左滑动,当前那一张摆放在右边,滑动到当前位置; $(".box>.LBnr").eq(prevIndex).animate({ left: -100+"%" }, 500) $(".box>.LBnr").eq(curIndex).css("left", "100%").animate({ left: 0 }, 500) } else if (prevIndex == 0 && curIndex == 2 ) { //边界1,当前在第一张,点击prev //向右滑动:前一张向右滑动,当前那一张摆放在左边,滑动到当前位置 $(".box>.LBnr").eq(prevIndex).animate({ left: 100+"%" }, 500) $(".box>.LBnr").eq(curIndex).css("left", "-100%").animate({ left: 0 }, 500) } else if (curIndex > prevIndex) { $(".box>.LBnr").eq(prevIndex).animate({ left: -100+"%" }, 500) $(".box>.LBnr").eq(curIndex).css("left", "100%").animate({ left: 0 }, 500) } else { $(".box>.LBnr").eq(prevIndex).animate({ left: 100+"%" }, 500) $(".box>.LBnr").eq(curIndex).css("left", "-100%").animate({ left: 0 }, 500) } //切小点; $(".nav li").eq(curIndex).addClass("on").siblings().removeClass() } // ]]> < > Massage Frame Wheels Seat Cushion // = 800 && screen.width >= screen.height) { $(".box>.ph_bf").remove() }else { $(".box>.pc_bf").remove() } }); var prevIndex2 = 0; var curIndex2 = 0; $(".next2").click(function() { var box=$(this).parent(); prevIndex2=box.attr("previndex2"); curIndex2=box.attr("curindex2"); //.is(":animated"):正在执行动画返回true,没在执行动画返回false if (box.children(".LBimg2").eq(curIndex2).is(":animated")) { return; } if (curIndex2 >= box.children(".LBimg2").length - 1) { curIndex2 = 0; } else { curIndex2++ } tab2(box); prevIndex2 = curIndex2; box.attr("previndex2",prevIndex2); box.attr("curindex2",curIndex2); }); $(".prev2").click(function() { var box=$(this).parent(); prevIndex2=box.attr("previndex2"); curIndex2=box.attr("curindex2"); if (box.children(".LBimg2").eq(curIndex2).is(":animated")) { return; } if (curIndex2 <= 0) { curIndex2 = box.children(".LBimg2").length - 1; } else { curIndex2--; } tab2(box); prevIndex2 = curIndex2; box.attr("previndex2",prevIndex2); box.attr("curindex2",curIndex2); }); $(".nav2 li").click(function() { var box=$(this).parent().parent(); prevIndex2=box.attr("previndex2"); curIndex2=box.attr("curindex2"); curIndex2 = $(this).index(); if (curIndex2 == prevIndex2) { return; } tab2(box); prevIndex2 = curIndex2; box.attr("previndex2",prevIndex2); box.attr("curindex2",curIndex2); }); //左边按钮:向右边滑动; function tab2(box) { var LBIdx = box.attr("lbindex2"); //切大图; if (curIndex2 == 0 && prevIndex2 == $(".LB"+LBIdx+" .nav2 li").length-1) { //边界2,当前在最后一张,点击next //向左滑动:前一张向左滑动,当前那一张摆放在右边,滑动到当前位置; box.children(".LBimg2").eq(prevIndex2).animate({ left: -100+"%" }, 500) box.children(".LBimg2").eq(curIndex2).css("left", "100%").animate({ left: 0 }, 500) } else if (prevIndex2 == 0 && curIndex2 == $(".LB"+LBIdx+" .nav2 li").length-1 ) { //边界1,当前在第一张,点击prev //向右滑动:前一张向右滑动,当前那一张摆放在左边,滑动到当前位置 box.children(".LBimg2").eq(prevIndex2).animate({ left: 100+"%" }, 500) box.children(".LBimg2").eq(curIndex2).css("left", "-100%").animate({ left: 0 }, 500) } else if (curIndex2 > prevIndex2) { box.children(".LBimg2").eq(prevIndex2).animate({ left: -100+"%" }, 500) box.children(".LBimg2").eq(curIndex2).css("left", "100%").animate({ left: 0 }, 500) } else { box.children(".LBimg2").eq(prevIndex2).animate({ left: 100+"%" }, 500) box.children(".LBimg2").eq(curIndex2).css("left", "-100%").animate({ left: 0 }, 500) } //切小点; $(".LB2_"+LBIdx+" .nav2 li").eq(curIndex2).addClass("on2").siblings().removeClass() } // ]]>