scroll 1000pixels down the page on element click

2019-08-09 01:38发布

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

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>

1条回答
何必那么认真
2楼-- · 2019-08-09 02:03

the javascript function you need would look something link this:

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

and for the html button, well, just:

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

best of luck

查看更多
登录 后发表回答