[英]how to scroll down a page using javascript
I have two Divs with skip hrefs
upon clicking the first href
skip it should automatically scroll down to the next div. 单击第一个
href
跳过时,我有两个带有skip href
hrefs
,它会自动向下滚动到下一个div。
I have tried like this 我已经试过了
<div class="skip"><a href='javascript:move_down()' onclick="skipWindow(2);">skip</a></div>
function move_down() {
window.scrollBy(0, 50);
}
What's wrong with using an anchor link, or in HTML5 terms, a fragment. 使用锚链接或HTML5术语片段有什么问题。 No JS required (although JS could insert the correct link/fragment if that's needed dynamically).
不需要JS(尽管JS可以动态地插入正确的链接/片段,但可以插入正确的链接/片段)。
See HTML Anchors with 'name' or 'id'? 看到带有“名称”或“ id”的HTML锚吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.