Anchor 平滑滚动 Posted on 2014-09-24 | In Front-End | 原代码出自 CSS-Tricks1234567891011121314$(function () { $('a[href*=#]:not([herf=#])').click(function(event) { 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) { $('html, body').animate({ scrollTop: target.offset().top }, 1000); return false; } } });})