1

以下是我为 scrollTop 函数编写的代码。它只会将 div 滚动到顶部,但我希望 div 从顶部向下移动 300px。谁能帮忙?

$(function() {
$("#button").on("click", function() {
    $("html, body"). animate({"scrollTop":$("#div").offset().top}, 1000);
    return false;
    });
});
4

1 回答 1

1
$("html, body"). animate({"scrollTop":$("#div").offset().top - 300}, 1000);
于 2013-11-04T16:21:49.313 回答