ztree设置JS代码
ztree是如何设置自定义图标的呢?下面我们来看一下:
var setting = {
check: {
enable: true
},
data: {
simpleData: {
enable: true
}
},
callback: {
onNodeCreated: zTreeOnNodeCreated
},
};
//定义函数zTreeOnNodeCreated
function zTreeOnNodeCreated(event, treeId, treeNode) {
//salesman是树节点的名称,不是树本身内置代码,需要后台定义
//该处判断假如treeNode节点是salersman,那么设置css样式
$('#'+treeNode.tId+'_ico').css("background", "url('../../../img/header.png') center center/15px 15px no-repeat");
//$('#'+treeNode.tId+'_ico')是多个赋值方式
}
}