// to top回到顶部
var timer = null;
$(window).scroll(function(){
var osTop = $(document).scrollTop();
if(osTop>=600){
$(".to_top").css("display","block")
}else{
$(".to_top").css("display","none")
}
});
$(".to_top").click(function(){
timer = setInterval(function(){//设置定时器
var osTop = $(document).scrollTop();//获取滚动条高
var ispeed = Math.floor(osTop/5);//ispeed 最后等于0
$(document).scrollTop(osTop-ispeed);
if(osTop==(osTop-ispeed)){
clearInterval(timer);//这里osTop==(osTop-ispeed)即ispeed等于0时 条件成立
timer=null;
}
},30);
});