- A+
所属分类:Web前端
页面平滑滚动锚点代码:
- $(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;
- }
- }
- });
- })

我的微信
分享交流WordPress经验与技巧,关注前端设计与网站制作。仅用于功能演示。