thinkcmf获取当前导航菜单

thinkcmf获取当前导航菜单栏

遍历当前菜单栏,将其跳转地址与当前浏览器地址对比,能对上的话即是当前菜单,加一个样式

$("#main-menu a").each(function () {
            console.log($(this)[0].href)
            if ($(this)[0].href == String(window.location)) {
                $(this).parentsUntil("#main-menu>ul>li").addClass("active");
            }
        });


猜你喜欢

转载自blog.csdn.net/asdlow/article/details/79282229
今日推荐