我收到錯誤:body.scrollTop在嚴格模式下不推薦使用。如果處於嚴格模式,請使用'documentElement.scrollTop',只有在quirks模式下才能使用'body.scrollTop'。
body.scrollTop在嚴格模式下不推薦使用。如果處於嚴格模式,請使用'documentElement.scrollTop',只有在quirks模式下才能使用'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? – njzk2
可能的重複http://stackoverflow.com/questions/19635188/why-is-body-scrolltop-deprecated – sgtdck
您正在尋找'document.documentElement'。這是''標籤創建的元素。 –