我需要在我的 url 上隐藏 anchor 。
<a href="#book">Book</a>
这个 anchor 附加在 jquery smooth scroll 上,当我点击我的 url 时变成:
www.test.it/#book
我不想在我的网址上出现#book。
有可能吗?
是否可以从另一个页面隐藏?
示例:www.test.it/#book 到 www.test.it
我在 boostrap 模态上看到了这个东西。
可以在这里看到,在我的网站上:http://www.alessandrapinto.it/
最佳答案
如果url中有#,默认会更新url。如果您不想在 URL 中添加#,则需要使用 jquery 来执行此操作。添加 Id 你的 anchor 我将其作为 id="name"然后将类添加到你的 div 直到你想要滚动页面的位置我将其作为 class="name"
$("#name").click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $(".name").offset().top
}, 2000);
});
关于javascript - 删除 URL 上的 #book anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32007099/