ztree.js 禁止点击事件和鼠标禁用
作者:互联网
先看样式
var _t = this; var setting = { view: { fontCss: { color: "#5E5F61" }, showIcon: true, showLine: false }, data: { simpleData: { enable: true } }, callback: { beforeClick: _t.beforeClick_, onClick: function (event, treeId, treeNode) { _t.zTreeOnClick(event, treeId, treeNode); } } }; zTree_Menu = $.fn.zTree.getZTreeObj("group_file"); var nodes = zTree_Menu.transformToArray(zTree_Menu.getNodes()); for (var i = 0; i < nodes.length; i++) { if (nodes[i].parentCode == "0" && nodes[i].name[nodes[i].name.length - 2] == "0") { //没有子级鼠标禁止 $("#" + nodes[i].tId).css({ "cursor": "not-allowed" }); $("#" + nodes[i].tId + '_ico').css("cursor", "not-allowed"); $("#" + nodes[i].tId + '_switch').css("cursor", "not-allowed"); } else { $("#" + nodes[i].tId).css("cursor", "pointer"); } } /**** * 单击树之前 */ beforeClick_: function (treeId, treeNode, clickFlag) { // 没有子级禁止点击 if (treeNode.parentCode == "0" && treeNode.name[treeNode.name.length - 2] == "0") { return false; } return true; } //html <div class="m-folders"> <ul id="group_file" class="ztree"></ul> </div>
标签:treeNode,鼠标,js,var,ztree,tId,nodes,css,name 来源: https://www.cnblogs.com/ht955/p/16229651.html