javascript - 链接到 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>
解决方案
推荐阅读
- python - 防止 python twitter bot 发布重复的状态更新
- python - 如何在 Python 中将具有给定 UTC 偏移量的日期时间字符串转换为具有更窄 UTC 偏移量的等效日期时间
- mysql - Laravel 查询构建器,将连接表作为嵌套数组
- firebase - Flutter Firebase 分配编号
- java - 实现 encodeCaesar
- javascript - 更改元素样式中数字的值
- java - 使用 cron 属性在 Spring-boot 中测试 @Scheduled 函数
- makefile - 我不希望 gnu make 在规则中将自动变量传递给 gnuplot 脚本
- python - 模块“cairo”没有“上下文”成员
- python - 从 Airflow 创建 Docker 容器,其中 Airflow 本身位于容器中(因为 Windows 10)。我错过了什么?