mcms导航菜单当前栏目高亮,支持下级栏目

独自空忆成欢 提交于 2020-08-05 05:08:06
数据库标签表增加属性
tagid=4的栏目标签26行增加path输出
category_path as path,
服务端标签增加 [field.path/]
{ms:channel typeid='' type=son ref=one}
<li class="nav-list" path="[field.path/]"> <span class="iconfont [field.typekeyword/]"></span> <a href="{ms:global.url/}[field.typelink/]">[field.typetitle/]</a>
    <ul>
        {ms:channel refs=one ref=two}
        <li><a href="{ms:global.url/}[field.typelink/]">[field.typetitle/]</a></li>
        {/ms:channel}
    </ul>
</li>
{/ms:channel}

js控制样式

<script>
    $(function () {
        var r=location.href;
        $(".nav-list").removeClass("active");
        var isIndex=true;
        $(".nav-list").each(function (index,item) {
            var _this=$(item);
            if(_this.attr("path")!=null && r.match(topurl)){
                _this.addClass("active");
                isIndex=false;
            }
        })
        if(isIndex){
            $(".nav-list").eq(0).addClass("active");
        }
    })
</script>

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!