1

这可能是一个愚蠢的问题,但我已经尝试了几件事,但似乎无法让它发挥作用。我希望简单地向我当前的导航添加硬/外部链接,该导航基于 this.hash (目前它是一个单页网站)。代码如下:

jQuery(".tabs-btn ul li a, .navbar-nav li a, .navbar-brand").click(function (event) {
    event.preventDefault();
    //calculate destination place
    var dest = 0;
    if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
        dest = $(document).height() - $(window).height();
    } else {
        dest = $(this.hash).offset().top;
    }
    //go to destination
    jQuery('html,body').animate({scrollTop: dest}, 1000, 'swing');
});

需要更改/添加什么以使此代码接受外部链接而不仅仅是哈希链接?谢谢!

4

0 回答 0