A strange manifestation of the jQuery toggle method.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.