Twitter Bootstrap - Tabs - URL doesn't change

前端 未结 15 1614
长情又很酷
长情又很酷 2020-11-28 18:53

I\'m using Twitter Bootstrap and its \"tabs\".

I have the following code:

15条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 19:14

    I am using Bootstrap 3.3.* and none of the above solution helped me, even marked as answer one. I just added below script and worked.

    $(function(){
        var hash = document.location.hash;
        if (hash) {
           $('.navbar-nav a[href="' + hash + '"]').tab('show');
        }
        $('a[data-toggle="tab"]').on('click', function (e) {
           history.pushState(null, null, $(this).attr('href'));
        });
    });
    

    Hope this helps you.

提交回复
热议问题