📅  最后修改于: 2022-03-11 15:01:44.056000             🧑  作者: Mango
//scroll to id
var $root = $('html, body');
$('a[href^="#"]').click(function () {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});