图片轮播 向左和向右

Jquery做的 ,比起JS要简洁多了

left=$(".left");
    right=$(".right");
    da=$(".da");
    
    c=1;
    
    left.click(function() {
        if(c != 5) {
            da.stop();
            da.animate(
                {
                    marginLeft: c * (-620) + "px"
                },
                1000,
                function() {
                    c++;
            })
        }
    })
    
    right.click(function() {
        if(c != 1) {
            da.stop();
            da.animate(
                {
                    marginLeft: (c-2)* (-620) + "px"
                },
                1000,
                function() {
                    c--;
            })
        }
    })

posted on 2017-10-13 16:11  段了的弦  阅读(143)  评论(0编辑  收藏  举报