Bootstrap平滑滚动到Anchor - jScript无法正常工作

时间:2013-04-04 13:53:39

标签: jquery twitter-bootstrap

我正在使用Twitters Bootstrap,我希望能够顺利滚动到我的主播,但它无法正常工作。这是我的文档的末尾,在</body>标记之前:

<script type="text/javascript">
!function ($) {
    $(function(){
        $('#running-box, #bg-car').carousel({});

        var $root = $('html, body');

        $('a').click(function() {
            var href = $.attr(this, 'href');
            $root.animate({
                scrollTop: $(href).offset().top
            }, 500, function () {
                window.location.hash = href;
            });
            return false;
        });
    })
}(window.jQuery)

</script>   

jQuery和Bootstrap正确包含在内......

1 个答案:

答案 0 :(得分:0)

如果您更换

 'a[href*=#]:not([href=#])' 

'a[href*=#]:not([href=#]):not([href=#idname])'

您可以阻止平滑滚动为该特定链接工作

相关问题