$("#toTop").bind("click",function(){
var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
if(scrollTop>200){
$("html,body").animate({scrollTop: 0},300);
}
});
原文:http://www.cnblogs.com/ouyang2014/p/4108376.html