var scrollmiddle = {' Odiv ':d ocument.getelementbyid (' comment '),//target Dom ' Oli ': document.getElementById (' Co Mment '). getElementsByTagName (' Li '), ' Times ': 30,//Configure scrolling time ' delay ': 1000,//configuration paused The time inint:function () {this.size = this.
Oli.length;
This.height = 59;
This.countheight =this.size * this.height; This. Odiv.innerhtml+=this.
odiv.innerhtml;
This.timer = null;
}, Scroll:function () {var _this = this;
_this.inint (); function scrolls () {var scrollvalue = _this.
Odiv.scrolltop;
var sub_timer = null;
var num=0; if (scrollvalue>=_this.countheight) {_this.
odiv.scrolltop = 0; }else{_this.
odiv.scrolltop++; if (scrollvalue%_this.height==0) {clearinterval (_this.timer) function delay () {num
++; if (num==3) {num= 0;
Clearinterval (Sub_timer);
Sub_timer = null;
Clearinterval (_this.timer) _this.timer = SetInterval (scrolls,_this.times);
return false; } Sub_timer = SetInterval (Delay,_this.delay)}}} This.time
R = setinterval (scrolls,_this.times); }
}
Call Method:
Scrollmiddle.scroll ();
HTML structure:
<ul id= "comment" >
<li></li> ...
</ul>
CSS structure:
#comment {
width:200px;
height:200px;
Overflow:hidden;
}
The above JS implementation can be paused vertical scrolling instance code is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.