【问题标题】:Automatically scroll down page自动向下滚动页面
【发布时间】:2014-10-02 08:44:27
【问题描述】:

我试图让我的页面上的特定 div 自动开始向下滚动,然后在页面加载后备份。

这是为我的 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 告诉我我有一个引用错误,并且 $ 没有定义。 我想要动画的 div 的 id 是 scrollingcontent。

感谢您的帮助!

【问题讨论】:

    标签: javascript jquery scroll vertical-scrolling


    【解决方案1】:

    检查你是否正确地附加了jQuery。

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

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

    希望这会有所帮助。干杯!

    【讨论】:

    • 我错过了那行,但是当我刷新页面时它仍然没有滚动。
    • 你真的有名为 (id) 的 div 作为“滚动内容”吗?如果您检查浏览器的内容是什么?有什么错误吗?
    • 是的,需要滚动的div在这里:
    猜你喜欢
    • 1970-01-01
    • 2020-09-05
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 2021-05-20
    • 1970-01-01
    • 2011-09-03
    • 2015-01-19
    相关资源
    最近更新 更多