Three parameters of AddEventListener

Source: Internet
Author: User

AddEventListener has three parameters: the first parameter represents the event name (without on, such as "click"), the second parameter represents the function to receive event handling, and the third parameter is usecapture, which is explained in this article.

The above is the code we tested, according to the display of info to determine the order of triggering, there are three AddEventListener, and usecapture optional value is true and false, so 2*2*2, you can draw 8 different programs.

    • When all is false, the triggering sequence is: Indiv, Middlediv, Outdiv;

    • When all is true, the triggering order is: Outdiv, Middlediv, Indiv;

    • Outdiv is true, when the other is false, the triggering order is: Outdiv, Indiv, Middlediv;

    • Middlediv is true, when the other is false, the triggering order is: Middlediv, Indiv, Outdiv;

    • ......

Finally, the following conclusions are drawn:

    • The triggering order of true is always before false;

    • If more than one is true, then the outer layer is triggered before the inner;

    • If more than one is false, the inner trigger precedes the outer layer.


Three parameters of AddEventListener

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.