jQuery网站左侧展开收缩图标导航菜单代码

来源:https://www.sucaihuo.com/js/4686.html 2019-08-27 12:02浏览(1190) 收藏

一款基于jQuery制作的网站左侧展开收缩图标导航菜单代码,收缩时只显示图标,展开时则显示图标和菜单名称,还支持二级菜单。
jQuery网站左侧展开收缩图标导航菜单代码
分类:导航菜单 > 二级菜单 难易:初级
查看演示 下载资源 下载积分: 40 积分
关注公众号,免费赠送安装视频教程、环境和学习视频,后面会不断更新。

js代码

<script src="jquery-3.4.1.min.js"></script>
<script>
  $(document).ready(function(){
    //展开收起
    $(".btn-nav").click(function () {
      $(".lvc-wrap").toggleClass("lvc-close")
      $("ol").toggleClass("small-ol")
      $(".next-layer ol").hide()

      if($("#lvc-nav").hasClass('lvc-close')){
        $(".next-layer ").removeClass("arrow")
      }
    })

    //选中状态
    $(".lvc-nav li").click(function () {
      $(this).siblings().find('ol').hide()
      $(this).addClass("active").siblings().removeClass("active")
    })

    //选中子集清除父级active
    $("ol>li").click(function (e) {
      console.log('ol>li clicked')
      e.stopPropagation()
     $(this).parent().parent().removeClass("active")
    })

    //二级导航展开收起
    $(".next-layer").click(function () {
      $(this).children("ol").toggle();
      $(this).toggleClass("arrow").siblings().removeClass("arrow")
    })


     $("ol li").click(function () {
       if($("ol").hasClass('small-ol')) {
         $(".small-ol").hide();
         $(this).parent().parent().addClass("active")
       }
     })
  })
</script>
评论1
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

  • 头像 沙发
    05-12 11:30
    x***0
    加豆腐谁带你飞惊世毒妃胡说八道赶紧看书电罚好吧会发生
1 2