functionBuildtree () {//$ ('. Tree Li:has (UL) '). addclass (' Parent_li '). Find (' > span '). attr (' title ', ' Collapse this branch ');$ ('. Tree Li.parent_li > Span '). On (' click ',function(e) {varChildren = $ ( This). Parent (' Li.parent_li '). Find (' > ul > Li '); if(Children.is (": Visible") {children.hide (' Fast '); $( This). attr (' title ', ' Expand this branch '). Find (' > i '). addclass (' Icon-plus-sign '). Removeclass (' icon-minus-sign ').); } Else{children.show (' Fast '); $( This). attr (' title ', ' Collapse this branch '). Find (' > i '). addclass (' Icon-minus-sign '). Removeclass (' icon-plus-sign ').); } e.stoppropagation (); }); $('. Child_li '). On (' click ',function(e) {$ ( This). Toggle (function(){ $("Input", $ ( This). attr ("Checked",true) }, function(){ $("Input", $ ( This). attr ("Checked",false) }); });}
Would have been to do a ul tree, Parent_li for the parent node, Child_li as a child node. When writing a click event, it is found that when a child node clicks on a toggle, the parent node's Click event is triggered first. No other methods are affected. Don't understand the principle.
A strange manifestation of the jQuery toggle method.