It's our wits that make us men.

锚点平滑滚动

Posted on By Wei Bin

====================================

      $(".navbar-item").on("click", "li > a", function(){
        // 激活态
        $(".navbar-item ul a").removeClass("active");
        $(this).addClass("active");

        var href = $(this).attr("href");
        if (href.substring(href.length - 1) != "#") {
            var pos = $(href).offset().top;
            $("html,body").animate({scrollTop: pos}, 300);
            return false;
        }
    });