How to get Twitter-Bootstrap navigation to show active link?

前端 未结 22 2095
一整个雨季
一整个雨季 2020-11-27 09:31

I\'m not understanding how Twitter Bootstrap does active links for the navigation. If I have a regular navigation like this (with ruby on rails linking):

<         


        
22条回答
  •  一生所求
    2020-11-27 10:07

    Use this instead to select active link in nav based on the current route without server code:

        $(document).ready(function () {
            $('a[href="' + this.location.pathname + '"]').parent().addClass('active');
        });
    

提交回复
热议问题