当前位置:Gxlcms > JavaScript > javascript实现文字图片上下滚动的具体实例

javascript实现文字图片上下滚动的具体实例

时间:2021-07-01 10:21:17 帮助过:2人阅读

代码如下:
<div style="border:#d3d3d3 1px solid;width:100%;">
         <div id="demo" style="overflow:hidden;height:160;width:100%;">
          <div id="demo1">
           文章标题列表
          </div>
          <div id="demo2"></div>
         </div>
        </div>
        <script language="javascript">
         var speed=30
         demo2.innerHTML=demo1.innerHTML
         function Marquee(){
         if(demo2.offsetTop-demo.scrollTop<=0)
         demo.scrollTop-=demo1.offsetHeight
         else{
         demo.scrollTop++
         }
         }
         var MyMar=setInterval(Marquee,speed)
         demo.onmouseover=function() {clearInterval(MyMar)}
         demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
        </script>

人气教程排行