简易列表滚动轮播,上下滚动

// ===========自动滚屏=============
        function ScrollList(name){
            this.list=document.getElementsByClassName(name)[0]
            this.prize_scroll=null
            var that=this
            this.list.addEventListener('mouseenter',function(){
                clearInterval(that.prize_scroll)
            })
            this.list.addEventListener('mouseleave',function(){
                that.init()
            })
        this.init=function(){
                clearInterval(that.prize_scroll)
                that.prize_scroll=setInterval(function(){
                    
                    that.list.scrollTop+=1
                    if(that.list.scrollTop==that.list.scrollHeight-that.list.offsetHeight){
                        
                        that.list.scrollTop=0
                    }
                },100)
            }
            
        }
    var scroll1=new ScrollList('tcont')//tcont需要overflow:auto
    scroll1.init()
原文地址:https://www.cnblogs.com/azure-zero/p/14836585.html