【发布时间】:2018-12-11 15:35:33
【问题描述】:
我在 html 上使用这个脚本:
$(function () {
$('table.menu a').bind('click', function (event) {
var $anchor = $(this);
//if you don't want to use the easing effects:
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 170
}, 1500);
event.preventDefault();
});
});
但我有一个问题,地址栏上没有出现链接名称...
我的问题是:如何在地址栏上写我的锚点?
【问题讨论】:
-
喜欢 url/#anchor 吗?删除 event.preventDefault();如果这是您想要的行为,则使 URL 指向 href。