jquery實現(xiàn)的鼠標下拉滾動置頂效果
更新時間:2014年07月24日 11:47:33 投稿:whsnow
鼠標下拉滾動置頂效果想必大家在瀏覽網(wǎng)頁時都有遇到過,下面有個不錯的小例子,需要的朋友可以參考下
$(function(){
//置頂按鈕顯示/隱藏實現(xiàn)
$(window).scroll(function(){
var w_height = $(window).height();//瀏覽器高度
var scroll_top = $(document).scrollTop();//滾動條到頂部的垂直高度
if(scroll_top > w_height){
$("#goto-top").fadeIn(500);
}else{
$("#goto-top").fadeOut(500);
}
});
//置頂
$("#goto-top").click(function(e){
e.preventDefault();
$(document.documentElement).animate({
scrollTop: 0
},200);
//支持chrome
$(document.body).animate({
scrollTop: 0
},200);
});
})
</script>
<style type="text/css">
#goto-top {
display:none;
position:fixed;
width:38px;
height:36px;
background:url(images/goto-top.png) no-repeat 0 0;
bottom:40px;
right:40px;
-webkit-transition:all 0.2s;
-moz-transition:all 0.2s;
-o-transition:all 0.2s;
transition:all 0.2s;
z-index:9999;
}
#goto-top:hover {
background:url(images/goto-top.png) no-repeat 0 -36px;
}
</style>
</head>
您可能感興趣的文章:
- jQuery滾動監(jiān)聽實現(xiàn)商城樓梯式導(dǎo)航效果
- jQuery實現(xiàn)可兼容IE6的滾動監(jiān)聽功能
- 基于jQuery實現(xiàn)手風(fēng)琴菜單、層級菜單、置頂菜單、無縫滾動效果
- JQuery插件iScroll實現(xiàn)下拉刷新,滾動翻頁特效
- js/jquery獲取瀏覽器窗口可視區(qū)域高度和寬度以及滾動條高度實現(xiàn)代碼
- jQuery scroll事件實現(xiàn)監(jiān)控滾動條分頁示例
- jQuery創(chuàng)建平滑的頁面滾動(頂部或底部)
- js,jquery滾動/跳轉(zhuǎn)頁面到指定位置的實現(xiàn)思路
- jquery無縫向上滾動實現(xiàn)代碼
- JS JQUERY實現(xiàn)滾動條自動滾到底的方法
- jQuery實現(xiàn)的監(jiān)聽導(dǎo)航滾動置頂狀態(tài)功能示例
相關(guān)文章
ashx文件獲取$.ajax()方法發(fā)送的數(shù)據(jù)
這篇文章主要介紹了ashx文件獲取$.ajax()方法發(fā)送的數(shù)據(jù)的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-05-05
jquery中$(#form :input)與$(#form input)的區(qū)別
本節(jié)為大家介紹下jquery 中$(#form :input)與$(#form input)的區(qū)別,需要的朋友可以參考下2014-08-08
jQuery+HTML5+CSS3制作支持響應(yīng)式布局時間軸插件
這篇文章主要為大家詳細介紹了JQuery+HTML5+CSS3制作時間軸,支持響應(yīng)式布局時間軸插件,感興趣的小伙伴們可以參考一下2016-08-08

