图片轮播和无缝滚动

                                              图片轮播和无缝滚动

$(function () {
    window.open("open.html");
    $(window).scroll(function () { // 页面发生scroll事件时触发 
        var st = $(this).scrollTop() + 50;//鼠标滚轮一周大概是50px;
        $("#right").css("top",st);
    });
    //点击关闭按钮  关闭广告图片
    $("#right").find("a").click(function () {
        $("#right").hide();
    });
    
    //图片轮播
    function changepic() {
        var index = 0;
        //作为鼠标是否悬停的标志
        var stop = false;
        var numbers = $("#scroll_number li");
        var imgs = $("#scroll_img li");
        numbers.eq(index).addClass("scroll_number_over").siblings().removeClass("scroll_number_over").stop(false);
        numbers.mouseover(function () {
            stop = true;
            index = $(this).text()-1;
            imgs.eq(index).stop(true).fadeIn().siblings().fadeOut();
            $(this).addClass("scroll_number_over").siblings().removeClass("scroll_number_over").stop(true);
        }).mouseout(function () {
            stop = false;
        });
        setInterval(function () {
            if (stop) {
                return
            } else {
                index++;
            };
            if (index >numbers.length-1) {
                index = 0;
            }
            imgs.eq(index).stop(false).fadeIn().siblings().fadeOut();
            numbers.eq(index).addClass("scroll_number_over").siblings().removeClass("scroll_number_over").stop(false);
        }, 3000);
     }
    changepic();
    //tab切换
    function changeTab() {
        var tabs = $(".book_type");
        var books = $(".book_class dl")
        tabs.mouseover(function () {
            $(this).addClass("book_type_out").siblings().removeClass("book_type_out");
            var num = tabs.index($(this));
            books.eq(0).addClass("book_none");
            books.eq(num).addClass("book_show").siblings().removeClass("book_show");
        });
        $(".book_class").children("dl").find("dd").mouseover(function () {
            $(this).css("border", "2px solid #F96");
        }).mouseout(function () {
            $(this).css("border", "2px solid #fff");
        });
    }
    changeTab();

    //无缝滚动
    function changebookName() {
        //定义离容器顶部的距离
        var margintop = 0;
        var stop = false;
        setInterval(function () {
            if (stop) return;
            $("#express").children("li").first().animate({"margin-top": margintop-- }, 0, function () {
                var firstli = $(this);
                //正在执行动画
                if (!firstli.is(":animated")) {
                    if ((-margintop) > firstli.height()) {//如果上边距和li的高度相同
                        //让该li拼接到末尾
                        firstli.css("margin-top", 0).appendTo($("#express"));
                        margintop = 0;
                    }
                }
            });
        },50);
        $("#express li").mouseover(function () {
            stop = true;
        }).mouseout(function () {
            stop = false;
        });  
    }
    changebookName();
});
原文地址:https://www.cnblogs.com/hmy-1365/p/5546297.html