页面平滑滚动锚点代码:文章源自知更鸟-https://zmingcx.com/jquery%e9%94%9a%e7%82%b9%e9%93%be%e6%8e%a5%e5%b9%b3%e6%bb%91%e6%bb%9a%e5%8a%a8%e6%95%88%e6%9e%9c.html
- $(function(){
- $('a[href*=#],area[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;
- }
- }
- });
- })

版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
评论