RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
layui树如何清空

小编给大家分享一下layui树如何清空,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

创新互联建站网站建设由有经验的网站设计师、开发人员和项目经理组成的专业建站团队,负责网站视觉设计、用户体验优化、交互设计和前端开发等方面的工作,以确保网站外观精美、成都网站设计、网站建设易于使用并且具有良好的响应性。

layui树怎么清空

首先创建一个树框:

基本树

layui树如何清空

基本树

    layui树如何清空

    在原有的树干上添加树杈:

    layui.use(['tree', 'layer'], function(){
      var layer = layui.layer
      ,$ = layui.jquery; 
      
      layui.tree({
        elem: '#demo1' //指定元素
        ,target: '_blank' //是否新选项卡打开(比如节点返回href才有效)
        ,click: function(item){ //点击节点回调
          layer.msg('当前节名称:'+ item.name + '
    全部参数:'+ JSON.stringify(item)); console.log(item); } ,nodes: [ //节点 { name: '树干' ,id: 2 ,spread: true ,children: [ { name: '树杈1' ,id: 21 ,spread: true }, { name: '树杈2' ,id: 22 } ] } ] });

    layui树如何清空

    再在之前的基础上添加树枝:

    layui.tree({
        elem: '#demo1' //指定元素
        ,target: '_blank' //是否新选项卡打开(比如节点返回href才有效)
        ,click: function(item){ //点击节点回调
          layer.msg('当前节名称:'+ item.name + '
    全部参数:'+ JSON.stringify(item)); console.log(item); } ,nodes: [ //节点 { name: '树干' ,id: 2 ,spread: true ,children: [ { name: '树杈1' ,id: 21 ,spread: true ,children: [ { name: '树枝' ,id: 211 } ] }, { name: '树杈2' ,id: 22 ,children: [ { name: '树枝' ,id: 221 } ] } ] } ] });

    layui树如何清空

    再在之前的基础上添加树叶:

    layui.tree({
        elem: '#demo1' //指定元素
        ,target: '_blank' //是否新选项卡打开(比如节点返回href才有效)
        ,click: function(item){ //点击节点回调
          layer.msg('当前节名称:'+ item.name + '
    全部参数:'+ JSON.stringify(item)); console.log(item); } ,nodes: [ //节点 { name: '树干' ,id: 2 ,spread: true ,children: [ { name: '树杈1' ,id: 21 ,spread: true ,children: [ { name: '树枝' ,id: 211 ,children: [ { name: '树叶1' ,id: 2111 }, { name: '树叶2' ,id: 2112 }, { name: '树叶3' ,id: 2113 } ] } ] }, { name: '树杈2' ,id: 22 ,children: [ { name: '树枝' ,id: 221 } ] } ] } ] });

    layui树如何清空

    添加个清空的按钮:

    layui树如何清空

    点击清空按钮,调用点击事件清除树

    $(".layui-btn").click(function(){
    $('ul li').remove();
    });

    layui树如何清空

    方法/步骤2

    完整代码:

    
    
    
      
      layui
      
      
      
      
      
    
    
                
    
    基本树

      看完了这篇文章,相信你对layui树如何清空有了一定的了解,想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


      网站题目:layui树如何清空
      网站路径:http://sczitong.cn/article/jssohg.html