在jquery中滚动到锚点时消除闪烁
Jquery做了应该做的事情,但是当我单击锚链接时,我无法摆脱闪烁 返回错误;似乎是在玩“登上顶峰”的把戏。另外,如果我想返回到上一页进行移动,我想保留pageurl在jquery中滚动到锚点时消除闪烁,jquery,Jquery,Jquery做了应该做的事情,但是当我单击锚链接时,我无法摆脱闪烁 返回错误;似乎是在玩“登上顶峰”的把戏。另外,如果我想返回到上一页进行移动,我想保留pageurl $("a.jump-to-link").click(function (event) { event.preventDefault(); $("html, body").animate({ scrollTop: $($(this).attr("href")).offset().top -50 }, 500
$("a.jump-to-link").click(function (event) {
event.preventDefault();
$("html, body").animate({ scrollTop:
$($(this).attr("href")).offset().top -50 }, 500);
window.location.hash = $(this).attr("href");
});
这是我的,如果你想检查代码的话。也许更改窗口哈希会起作用,所以你可以将窗口哈希更改放入scroll的回调函数中
$("html, body").animate({ scrollTop:
$($(this).attr("href")).offset().top -50 }, 500, function() {
window.location.hash = $(this).attr("href");
}
);
我注意不到闪烁,在这里工作平稳,可能重复