<!DOCTYPE html>
<meta charset="utf-8">

<title>tab选项卡学习</title>
<style>
html,body,ul,li{padding:0;margin:0}
ul{list-style-type:none}
clear{ clear:both;}
.box{ width:960px; height:2000px; margin:0 auto; background:#999;}
span{ position:fixed; _position:absolute; top:0; left:0; width:20px; border:1px solid #666; display:none;}
</style>
<div class="box"></div>
<span>返回顶部</span>

<script src="jquery-1.8.3.min.js"></script>
<script>
$(window).scroll(function(){
    var ws=$(window).scrollTop(),
        wh=$(window).height(),
        nw=$(window).width(),
        lv=(nw-960)/2+970,
        xx=$('span').height()+120;
        //console.log(ws);
    if(ws){
        $('span').show().css({left:lv,top:wh-xx});
        if($.browser.msie&&($.browser.version === "6.0")){
                $('span').css("top",wh-xx+ws);
            }
    }else{
        $('span').hide();
    }
    
    
});
    $('span').click(function(){
        $(window).scrollTop(0);
    });

</script>


























posted on 2014-02-28 10:31  N&#179;  阅读(140)  评论(0编辑  收藏  举报