jQuery滚动到页面顶部

jQuery滚动到页面顶部

问题描述:

有没有一种方法可以使用jQuery以编程方式滚动到页面顶部?我目前正在尝试使用以下代码执行此操作,但无法正常工作.我目前正在使用Firefox,

Is there a way to programmatically scroll to the top of a page with jQuery? I am currently trying to do this with the following code but it is not working. I am using Firefox currently,

$(window).scrollTop($(document).height());

尝试一下:

$('html, body').animate({scrollTop: '0px'}, 300);

您可以立即使用0而不是300进行此操作,但这会带来快速的自动滚动效果.

You can do this with 0 instead of 300 to be instant, but this gives a quick auto-scroll effect.