我有一个UL导航,我使用了这个平滑滚动的jQuery:
$(document).ready(function () {
$(document).on("scroll", onScroll);
//smoothscroll
$('a[href^="#"]').on('click', function (e) {
e.preventDefault();
$(document).off("scroll");
$('a').each(function () {
$('.nav').removeClass('active');
})
$('.nav').addClass('active');
var target = this.hash,
menu = target;
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top-59
}, 500, 'swing', function () {
window.location.hash = target;
$(document).on("scroll", onScroll);
});
});
});
它向下移动了59像素,这是我需要的除一个锚点外的所有内容,是否可以添加一行代码,说“除了X类”或其他什么?我是Jquery新手 ;)
非常感谢您的帮助。