【发布时间】:2014-01-21 20:29:40
【问题描述】:
我收到错误消息:
body.scrollTop 在严格模式下已弃用。请在严格模式下使用“documentElement.scrollTop”,仅在怪癖模式下使用“body.scrollTop”。
我的代码是:
$(document).ready(function(){
//Animates Scrolling to anchor
function scrollToAnchor(aid){
var divTag = $("div[name='"+ aid +"']");
$('html,body').animate({scrollTop: divTag.offset().top},'slow');
}
//If Checking out as guest, scroll to Shipping Information
$("#ReadDescription").click(function() {
scrollToAnchor('longdescreadmore');
});
});
如何编辑我的代码以使用此 documentElement.ScrollTop?
【问题讨论】:
-
考虑使用 document.scrollTop 代替 scrollTop 吗?
-
您正在寻找
document.documentElement。这就是<html>标签创建的元素。 -
@DaggNabbit 这让我很困惑。呵呵。我应该把它放在哪里?
-
@user2433689 我猜你会想要
$('html')而不是严格模式下的$('html,body')。
标签: javascript jquery deprecated