【发布时间】:2014-02-05 01:49:36
【问题描述】:
我正在关注这篇文章。
Scroll to the center of viewport
我确实喜欢这个答案,但是当我使用它时,我的控制台出现错误。
$('body').animate({
scrollTop: $(this).offset().top - ($(window).height()-$(this).outerHeight(true)) / 2
}, 5000);
错误:
未捕获的类型错误:无法读取未定义的属性“顶部”
我不知道为什么$(this).offset() is undefined。谁能帮帮我?
谢谢!
【问题讨论】:
-
我没有收到任何错误
标签: javascript jquery css