用jQuery实现网页卷轴的效果
生活随笔
收集整理的這篇文章主要介紹了
用jQuery实现网页卷轴的效果
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用jQuery實現網頁卷軸的效果:http://www.56mp.cn/UPLOAD/SmoothPageScroll/ jQuery有能力做出這樣的動畫滾動,利用其動畫功能和“ scrollTop ”參數。 最好的處理方法是在您的網頁上設置滾動指標散列標記的鏈接(如 #about)。您設置的“href” 的錨鏈指向鏈接“#target”,然后鏈接會跳轉到網頁元素在該網頁上的“target”作為其編號。這意味著它將不論已啟用JavaScript或不啟用都能動行。 以下是代碼: $(function(){ $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,body').animate({scrollTop: targetOffset}, 1000); return false;} } }); });
轉載于:https://www.cnblogs.com/zhangji/archive/2010/09/08/1821624.html
總結
以上是生活随笔為你收集整理的用jQuery实现网页卷轴的效果的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求一个整数n对16求商和余数
- 下一篇: 在Visual Studio 2005中