📌  相关文章
📜  a go to id js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:44.056000             🧑  作者: Mango

代码示例1
//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;
    });