我有以下的jQuery代码。
这是一个滚动插件,可以平稳地向页面内部链接滚动。我想将学校偏移-140px,这样它就不会直接滚动到DIV。如何实现?
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
这是一个滚动插件,可以平稳地向页面内部链接滚动。我想将学校偏移-140px,这样它就不会直接滚动到DIV。如何实现?