【发布时间】:2015-02-18 14:25:33
【问题描述】:
我有一点 js 问题。这是我的代码
$(document).on("scroll", onScroll);
$('a[href^="#"]').on('click', function (e) {
e.preventDefault();
$(document).off("scroll");
$('a').each(function () {
$(this).removeClass('active');
})
$(this).addClass('active');
var target = this.hash,
menu = target;
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top - 53}, 1000, 'swing', function () {
window.location.hash = target;
$(document).on("scroll", onScroll);
});
});
如您所见,我在目标上方设置了 53px 的偏移量。 53px 是我的固定菜单栏的高度
我想在移动设备上将此偏移设置为 0,因为菜单栏是隐藏的。
怎么做?
【问题讨论】:
标签: javascript jquery mobile scroll offset