追影 发表于 2014-7-1 10:11:25

jquery的dtree添加checkbox复选框

本帖最后由 追影 于 2014-7-1 10:14 编辑

dtree是个很不错的无限极客户端分类jquery控件,默认的支持checkbox,但很多时候又要用到 所以给加了复选框 不影响原来控件使用
主页:http://destroydrop.com/javascripts/tree/default.html下载:http://destroydrop.com/javascripts/tree/dtree.zip示例:http://destroydrop.com/javascripts/tree/default.html

<script>
    t = new dTree('t');
                t.add(0,-1,'管理内容权限');
<volist name="type_tree" id="vo">
                t.add({$vo.typeid},{$vo.fid},'<input name="typeids[]" type="checkbox" value="{$vo.typeid}" id="l{$vo.typeid}" pId="l{$vo.fid}">{$vo.typename}');
</volist>
      document.write(t);
               
                $("input").click(function(){
                   var pId=this.id;
                                 var id =$(this).attr("pId");
                                  //alert(id);
                   var checked=this.checked;
                                 $("input").attr("checked",checked);
                  findparent(id);
                                  findChild(pId);
                                  //选中父节点
                                  function findparent(id){
                                 var children=$("input").attr("checked",checked);
                        if(children.length>0){
                               children.each(function(){
                                                                   var tid =$(this).attr("pId");
                                 findparent(tid);
                     });
                        }            
                                 }
                                 //选中子节点
                  function findChild(pId){
                        var children=$("input").attr("checked",checked);
                        if(children.length>0){
                               children.each(function(){
                                 findChild(this.id);
                     });
                        }
         }
      });
               </script>

爱笑小猪猪 发表于 2015-10-15 11:53:49

厉害啊进来瞅瞅啊

xiaoshimu 发表于 2016-8-26 15:06:06

页: [1]
查看完整版本: jquery的dtree添加checkbox复选框