在元素点击时向下滚动1000pixels [英] scroll 1000pixels down the page on element click

查看:158
本文介绍了在元素点击时向下滚动1000pixels的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 div id =menuitem1,当有人点击该div时,我想要该页面滚动 1000px 向下翻页。

I have div id="menuitem1" and, when someone clicks on that div, I want the page to scroll 1000px down the page.

我知道这对Google来说很容易,但由于某些原因,即使在阅读文章和尝试各种各样的事情后,我也无法想象。我是新的这个东西,所以请理解这一点。谢谢!

I know this is something that's easy to Google, but for some reason, even after reading articles and trying all sorts of things, I can't figure it out. I'm new to this stuff, so please be understanding of that. Thanks!

<script type="text/javascript">
$("#menuitem1").click(function(){
$(window).scrollTo( {top:'1000px'}, 800 );
});
</script>


推荐答案

function pageScroll() {
        window.scrollBy(0,1000); // horizontal and vertical scroll increments
}

<input type="button" onClick="pageScroll()" value="Scroll Page">

运气最好的

这篇关于在元素点击时向下滚动1000pixels的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆