简体   繁体   English

自动向下滚动页面

[英]Automatically scroll down page

I am trying to get a specific div on my page to automatically start scrolling down, then back up once the page loads. 我正在尝试在页面上获取特定的div,以自动开始向下滚动,然后在页面加载后进行备份。

I have this written for my javascript: 我为我的JavaScript编写了此代码:

<script> function scroll(speed) {
$('#scrollingcontent').animate({ scrollTop: $(document).height() - $(window).height() }, speed, function() {
    $(this).animate({ scrollTop: 0 }, speed);
});
}

speed = 1000;

scroll(speed)
setInterval(function(){scroll(speed)}, speed * 2);</script>

Chrome is telling me that I have a reference error, and that $ is not defined. Chrome告诉我我有参考错误,并且未定义$。 My div that i want animated has the id of scrollingcontent. 我想要动画化的div具有scrollingcontent的ID。

Thanks for any help! 谢谢你的帮助!

Check whether you have attached jQuery properly or not. 检查您是否正确连接了jQuery。

<head>
<script src="jquery-1.11.1.min.js"></script>
</head>

More : - http://www.w3schools.com/jquery/jquery_install.asp 更多:-http: //www.w3schools.com/jquery/jquery_install.asp

Hope this helps. 希望这可以帮助。 Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM