last li menu to stay active

Viewed 11

How can I keep the sessions li active when the user is not on "About" or "Index" page?

<ul class="rd-navbar-nav">
<li>
     <a href="@Url.Action("Index", "Home")">Home</a>
</li>
<li>
     <a href="@Url.Action("About", "Home")">About Me</a>
</li>
<li>
     <a href="@Url.Action("Sessions", "Home")">Schedule A Healing Session</a>
</li>

$(document).ready(function () {

        var url = window.location.href;
        var FileName = url.substr(url.lastIndexOf("/") + 1);
        $('nav li').find('.active').removeClass('active');
        $('nav li a').filter(function () {
            return this.href == url;
        }).parent().addClass('active');

        if (FileName != "Index" && FileName != "About")
        {
            //Here I want to keep "Sessions" active if the user did not select Index or About 
        }

    });
0 Answers
Related