手写jquery生成无限极的菜单

{
“name”: “菜单0”,
“url”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”,
“child”: [],
“backgroundImage”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”
},
{
“name”: “菜单1”,
“url”: “https://img0.baidu.com/it/u=1780747315,948203002&fm=253&fmt=auto&app=138&f=JPEG?w=435&h=500”,
“child”: [
{
“name”: “菜单0”,
“url”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”,
“child”: [],
“backgroundImage”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”
}
],
“backgroundImage”: “https://img0.baidu.com/it/u=1780747315,948203002&fm=253&fmt=auto&app=138&f=JPEG?w=435&h=500”
},
{
“name”: “菜单2”,
“url”: “https://img0.baidu.com/it/u=2048261222,989660233&fm=253&fmt=auto?w=800&h=1411”,
“child”: [
{
“name”: “菜单0”,
“url”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”,
“child”: [],
“backgroundImage”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”
},
{
“name”: “菜单1”,
“url”: “https://img0.baidu.com/it/u=1780747315,948203002&fm=253&fmt=auto&app=138&f=JPEG?w=435&h=500”,
“child”: [
{
“name”: “菜单0”,
“url”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”,
“child”: [],
“backgroundImage”: “https://img2.baidu.com/it/u=170788176,908879950&fm=253&fmt=auto&app=138&f=JPEG?w=281&h=499”
}
],
“backgroundImage”: “https://img0.baidu.com/it/u=1780747315,948203002&fm=253&fmt=auto&app=138&f=JPEG?w=435&h=500”
}
],
“backgroundImage”: “https://img0.baidu.com/it/u=2048261222,989660233&fm=253&fmt=auto?w=800&h=1411”
}
]


###### html:



    ```
    js(需要引入jquery):
    
      $(function (){
        init();
        closeAndOpen();
      });
      function closeAndOpen(){
        $("body").on("mouseup","li",function (e) {
          var children = $(this).find(".menu-ul");
          children.toggle(500);
          e.stopPropagation();
        });
      }
      function init(){
        $(".parent>ul>li>ul").remove();
       /* $.ajax({
          url: '/test/array',
          type: 'GET',
          dataType: 'json',
        }).done(function (data) {
          if (data.rs) {
            var res = data.data;
            var h1 = "<li>菜单";
            h1 =ul(res,h1);
            h1+="</li>";
            $(".parent>ul").append(h1);
            $(".parent>ul>li>ul").hide();
          }
        }).fail(function () {
        });*/
        
        
        // data为后端传入前端的数据(上面注明了)
          var res = data;
          var h1 = "<li>菜单";
          h1 =ul(res,h1);
          h1+="</li>";
          $(".parent>ul").append(h1);
         // $(".parent>ul>li>ul").hide();
    
    
    ### 最后
    
    除了简历做到位,面试题也必不可少,整理了些题目,前面有117道汇总的面试到的题目,后面包括了HTML、CSS、JS、ES6、vue、微信小程序、项目类问题、笔试编程类题等专题。
    
    
    
      ![](https://img-blog.csdnimg.cn/img_convert/64ce8432d0f753e43f93972ad19fcd72.png)
    
    
    ![](https://img-blog.csdnimg.cn/img_convert/d508b1ae6a5e7d5e7d5daf668e9eccea.png)
    
    
    • 3
      点赞
    • 6
      收藏
      觉得还不错? 一键收藏
    • 0
      评论

    “相关推荐”对你有帮助么?

    • 非常没帮助
    • 没帮助
    • 一般
    • 有帮助
    • 非常有帮助
    提交
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值