js返回顶部的代码
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script> <style> #backToTop{ position:fixed; _position:absolute; bottom:50px; right:0; z-index:999999; display:block; } a.backToTop_a{ background:url(images/7_08.png) no-repeat; width:68px; height:79px; display:block; } a.backToTop_a:active{ background:url(images/7_11.png) no-repeat; } </style> <div id="backToTop"> <a href="javascript:void(0)" onfocus="this.blur();" class="backToTop_a png"></a> </div> <script> $("#backToTop").live("click", function(){ var _this = $(this); $('html,body').animate({ scrollTop: 0 }, 500 ,function(){ _this.hide(); }); }); $(window).scroll(function(){ var htmlTop = $(document).scrollTop(); if( htmlTop > 0){ $("#backToTop").show(); }else{ $("#backToTop").hide(); } }); </script>