首页 > 解决方案 > 链接到 Javascript 的按钮

问题描述

我正在使用以下脚本将页面滚动 X 像素。下面的脚本使用了一个按钮并且运行良好。但是,我想在页面的不同部分使用另一个按钮来触发事件。我试图弄清楚如何使用enter code here类或 id 链接该按钮。

  function ScrollBy100 () {
    window.scrollBy (0,100);
        }
    <div style="height:500px; background-color:#a0e0e0;">
    <button onclick="ScrollBy100 ()">Scroll the document vertically by 100 pixels!</button>
    <br />The height of this field is 100 pixels.
    </div>

标签: javascript

解决方案


推荐阅读