JS Code: $ (function () {Inittree ("DXTXL", Const_url. Load_dxtree, "id", "Yhzid");//Initialize SMS Address Book Inittree ("Yjtxl", Const_url. Load_yjtree, "id", "Yhzid");//Initialize mail Address Book}//Build Ztreefunction Inittree (ztreeid,url,id,pid) {var setting = {che CK: {enable:true//Show checkbox}, Data: {key: {name: ' XM '}, Simpledata: {Enab Le:true, IdKey: "id", PIdKey: "Yhzid"}}, callback: {Oncheck:getcheckeddata CheckBox Value Change Trigger method}};$.ajax ({type: "Get", DataType: "JSON", Url:url, Success:function (data) {$.fn.ztree.init ($ ("#" +ztreeid), setting, Data.data); } });} Trigger method function Getcheckeddata (E,treeid,treenode) {if (treenode.checked) {//Tick action if (treenode.isparent) {//Determine if parent section Point var childrennodes = Treenode.children; Gets the child node of the object if (childrennodes) {$.each (Childrennodes,function () { Setdxoryj (this); To the input box set value}); }}else{setdxoryj (TreeNode);}} else{//Uncheck operation if (treenode.isparent) {var childrennodes = Treenode.children; if (childrennodes) {$.each (Childrennodes, function () {cleardxoryj (this);//Empty the value of the input box }); }}else{cleardxoryj (TreeNode);}}} Go to the Recipient input box set value function Setdxoryj (treeNode) {if (treenode.txllx== "001") {///SMS Address Book if ($ (' #dxsxr '). val () = = "") {$ (' #dxsxr ') ). Val (TREENODE.SJ);} else{$ (' #dxsxr '). Val ($ (' #dxsxr '). Val () + ";" +TREENODE.SJ);}} else if (treenode.txllx== "002") {//mail Address Book if ($ (' #yjsjr '). val () = = "") {$ (' #yjsjr '). Val (Treenode.dzyj);} else{$ (' #yjsjr '). Val ($ (' #yjsjr '). Val () + ";" +treenode.dzyj);}}} Eliminate the value of the Recipient input box function Cleardxoryj (treeNode) {var data = "", if (treenode.txllx== "001") {//SMS Address Book var dxdata = ($ (' #dxsxr '). Val ()). Split (";"); for (Var i=0;i<dxdata.length;i++) {if (Treenode.sj!=dxdata[i]) {if (data== "") {data + = Dxdata[i];} Else{data+= ";" +dxdata[i];}};} $ (' #dxsxr '). val (data);} else if (treenode.txllx== "002") {//mail address Book var yjdata = $ (' #yjsjr '). Val (). Split (";"); for (Var i=0;i<yjdata.length;i++) {if (Treenode.dzyj!=yjdata[i]) {if (data== "") {data + = Yjdata[i];} Else{data + = ";" +yjdata[i];}};} $ (' #yjsjr '). val (data);}}
jquery and Ztree tree structure test Demo 2