JS实现滚动窗口

2022-08-22 11:29:13

这里写图片描述

<scripttype="text/javascript">
    window.onload =function(){var speed =20;var td1 = document.getElementById("td1");var td2 = document.getElementById("td2");
        td2.innerHTML = td1.innerHTML;var div1 = document.getElementById("div1");functiongoLeft(){if (td1.offsetWidth - div1.scrollLeft <0) {
                div1.scrollLeft = div1.scrollLeft - td1.offsetWidth;
            }else {
                div1.scrollLeft++;
            }
        }
        setInterval(goLeft,speed);
    }</script><divid="div1"style="overflow:hidden;width:800px;height:50px;"><tablestyle="width: 800px;height: 45px;background-color: silver;"><tr><tdid="td1"><tablestyle="width: 800px;height: 45px;background-color: silver;"><tr><tdalign="center"><fontsize="5px"color=blue>JS实现滚动窗口</font></td></tr></table></td><tdid="td2"></td></tr></table></div>
  • 作者:Truman in coding
  • 原文链接:https://blog.csdn.net/baidu_34219514/article/details/76650870
    更新时间:2022-08-22 11:29:13