chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//1个是父级名。
$(function(){
imgscrool('#ban');
})
function imgscrool(obj){
    var width = $(obj+" .banner .img img").width();
    var i=0;
    var clone=$(obj+" .banner .img li").first().clone();
    $(obj+" .banner .img").append(clone);
    var size=$(obj+" .banner .img li").size();
    for(var j=0;j<size-1;j++){
        $(obj+" .banner .num").append("<li><a></a></li>");
    }
    $(obj+" .banner .num li").first().addClass("hp_banner_gd_list_cur");
    /*鼠标划入圆点*/
    $(obj+" .banner .num li").hover(function(){
        var index=$(this).index();
        i=index;
        $(obj+" .banner .img").stop().animate({left:-index*width},500);
        $(this).addClass("hp_banner_gd_list_cur").siblings().removeClass("hp_banner_gd_list_cur");    
    })
    /*自动轮播*/
    var t=setInterval(function(){
        i++;
        move();
    },2000)
 
    /*对banner定时器的操作*/
    $(obj+" .banner").hover(function(){
        clearInterval(t);
    },function(){
        t=setInterval(function(){
            i++;
            move();
        },2000)
    })
    /*向左的按钮*/
    $(obj+" .banner .hp_banner_icon_ft").stop(true).delay(800).click(function(){
        i--;
        move();    
    })
    /*向右的按钮*/
    $(obj+" .banner .hp_banner_icon_rt").stop(true).delay(800).click(function(){
        i++;
        move();
    })
    function move(){
        if(i==size){
            $(obj+" .banner  .img").css({left:0});
            i=1;
        }
        // 修改轮播没屏宽度
        if(i==-1){
            $(obj+" .banner .img").css({left:-(size-1)*width});
            i=size-2;
        }
        $(obj+" .banner .img").stop(true).animate({left:-i*width},1000);
        if(i==size-1){
            $(obj+" .banner .num li").eq(0).addClass("hp_banner_gd_list_cur").siblings().removeClass("hp_banner_gd_list_cur")    
        }else{
            $(obj+" .banner .num li").eq(i).addClass("hp_banner_gd_list_cur").siblings().removeClass("hp_banner_gd_list_cur")    
        }
    }    
}