1、问题背景
系统利用zTree插件生成下拉复选树,点击文字勾选复选框
2、实现源码
<!DOCTYPE html> <html> <head> <title>zTree点击文字勾选复选框</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../css/demo.css" type="text/css"> <link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css"> <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="../../../js/jquery.ztree.core.js"></script> <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script> <script type="text/javascript"> $(document).ready(function(){ //初始化树 zTree = $.fn.zTree.init($("#treeSelect"), setting, datas); }); //设置 var setting = { check: { enable: true }, data: { simpleData: { enable: true } }, callback: { onClick: function (e, treeId, treeNode, clickFlag) { zTree.checkNode(treeNode, !treeNode.checked, true); } }, }, zTree; //数据 var datas =[ { id:1, pId:0, name:"树", open:true}, { id:11, pId:1, name:"松树", open:true}, { id:12, pId:1, name:"樟树", open:true}, { id:2, pId:0, name:"花", checked:true, open:true}, { id:21, pId:2, name:"梅花"}, { id:22, pId:2, name:"桃花", open:true} ]; </script> </head> <body> <p style="vertical-align: middle; text-align: center;"> <p> <ul id="treeSelect" class="ztree"></ul> </p> </p> </body> </html>
3、实现结果
以上就是zTree点击文字勾选复选框的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!