The result of this method is: "When a node is selected, the selected status of its child nodes also changes with the selected status of the current node. When the current node is selected, all its ancestor nodes should also be selected. If the node is canceled, the selected state of its ancestor node should be determined based on whether the same level node is selected ."
Note: The tree is generated using the TreeView control of.
The Code is as follows:
Copy codeThe Code is as follows:
JQuery (function (){
JQuery (": checkbox"). click (function (){
Var objNode = this;
Var objNodeId = objNode. id;
Var divObjId = objNodeId. substring (0, objNodeId. indexOf ("CheckBox") </span> + "Nodes ";
JQuery ('#' + divObjId + 'input [type = "checkbox"] '). each (function (){
This. checked = objNode. checked;
}
);
JQuery ("#" + objNodeId). parents ("div [id]"). each (function (){
Var divId = this. id;
Var cbId = divId. substring (0, divId. indexOf ("Nodes") + "CheckBox ";
Var cbCount = jQuery ('#' + divId + 'input: checked ');
If (objNode. checked | cbCount. length = 0)
{
Var sId = document. getElementById (cbId );
If (sId)
{
SId. checked = objNode. checked;
}
}
}
);
});
});