我看到这个小提琴样本
here
我想要当“到顶部”出现时,点击!应该滚动到顶部平滑或缓慢
$(window).scroll(function() { if ($(this).scrollTop()) { $('#toTop').fadeIn(); } else { $('#toTop').fadeOut(); } });
解决方法
$("#toTop").click(function () { //1 second of animation time //html works for FFX but not Chrome //body works for Chrome but not FFX //This strange selector seems to work universally $("html,body").animate({scrollTop: 0},1000); });