轮播图
$(function () {
var current =0;
var count=$(".pics-list>li").length;
//动画
function move() {
$(".points-list>li").eq(current).addClass("active").siblings().removeClass("active")
$(".pics-list").css("left",-1200 * current + "px")
}
//下一张图的轮播
function next() {
if (current < count - 1) {
current++;
}else{
current=0;
}
move();
}
//轮播图时间 给时间一个timer 在鼠标移入移出的时候调用
var timer=setInterval(() => {
next();
}, 1000);
//鼠标移入移出
$(".banner-box").hover(function() {
clearInterval(timer);//移入清理定时器
},function () {
//移出加上定时器
timer=setInterval(() => {
next();
}, 1000);
})
//圆点
$(".points-list>li").click(function () {
current=$(this).index();//获取下标
move();//调用
})
//左边箭头
$(".buts>.next").click(function(){
next();
move();
})
//右边箭头
$(".buts>.prev").click(function(){
if (current>0) {
current--;
}else{
current=count - 1;
}
move();
})
})
$(function () {
$(".top-list .title").click(function () {
$(this).addClass("active").siblings().removeClass("active");
$(".top-list-main ul").eq($(this).index()).show().siblings().hide()
})
})
浙公网安备 33010602011771号