jQuery实现 返回顶部
//若出现滚动条,且超出30px则,出现那个图片
var st = jQuery(document).scrollTop(),winh = jQuery(window).height;
var topImg = document.getElementById("topImg");
window.onscroll = function(){
st = jQuery(document).scrollTop(),winh = jQuery(window).height();
if(st > 30){
topImg.style.display = "inline";
topImg.style.top = st + winh -150 +"px";
}else{
topImg.style.display = "none";
}
}
//点击那图片,回到顶部
function clickTop(){
jQuery("html,body").animate({scrollTop:0},120);
topImg.style.display = "none";
}