标签:io os ar div sp cti on c ef
获取元素的固定位置: var y=$("#goToTop").offset().top;[可以根据y 的值,改变元素的定位方式position:fixed.]
#goToTop{ width:67px; height:68px;position:fixed; bottom:220px; right:0; background:#f00 url(../images/topBtns.png) no-repeat left top; display:none;}
<div id="goToTop"></div>
<script>
$(function(){
$(window).scroll(function(e) {
var scrollTop=$(window).scrollTop();
var windowHeight=$(window).height();
if(scrollTop>windowHeight){
$("#goToTop").show();
}else{
$("#goToTop").hide();
}
});
var gotoTop=function(){
window.scrollTo(0,0);
};
$("#goToTop").on("click",function(){
gotoTop();
});
});
</script>
标签:io os ar div sp cti on c ef
原文地址:http://www.cnblogs.com/dingyuanxin/p/3979528.html