三十八、天天快报(滚动)

function Scroll(){}
Scroll.prototype.upScroll=function(dom,_h,interval){var dom=document.getElementById(dom);var timer=setTimeout(function(){var _field=dom.firstElementChild;_field.style.marginTop=_h;clearTimeout(timer);},1000)
setInterval(function(){var _field=dom.firstElementChild;_field.style.marginTop="0px";dom.appendChild(_field);var _field=dom.firstElementChild
_field.style.marginTop=_h;},interval)}
var myScroll=new Scroll();

  

引入以上的js,然后初始化

初始化
myScroll.upScroll("demo", "-1.35rem", 3000);
注:demo为ul的id,-1.35rem是li的高度,滚动的是li
<ul>
    <li></li>
</ul>

  

原文地址:https://www.cnblogs.com/deng-jie/p/10075112.html