window.onscroll = function(){
var backBtn = document.getElementById("backTop");
backBtn.onclick = function(){
//将滚动距离设为0,则回到顶部
document.documentElement.scrollTop = document.body.scrollTop = 0;
}
//计算滚动的距离
var _top = document.documentElement.scrollTop + document.body.scrollTop;
//if(距离 > 1000) 显示回到顶部的按钮
if(_top > 1000) {
backBtn.style.display = "block";
} else {
backBtn.style.display = "none";
}
}