How to highlight active page in a masterpage menu?

后端 未结 6 1521
粉色の甜心
粉色の甜心 2020-12-10 17:24

I have a menu inside a masterpage (in a ASP.NET Web site), and i want to highlight active page in masterpage menu and submenus.

HTML:

&l         


        
6条回答
  •  悲&欢浪女
    2020-12-10 17:38

    $(function () {
            $(".navbar‐btn a").each(function () {
                var hreff = this.href.trim().split("/").splice(3, 4);
    
                if (hreff.length > 1)
                    hreff.splice(0, 1);
    
                if (hreff[0] == window.location.pathname.split("/").splice(1, 1)[0])
                    $(this).parent().addClass("active");
            });
        })
    

提交回复
热议问题