How to handle JS binding events and removing events

Source: Internet
Author: User

AddEventListener () and RemoveEventListener () are used to process the specified and delete event handler actions. Both methods are included in all DOM nodes, and they all accept 3 parameters: the name of the event to be processed, the function that is the event handler, and a Boolean value. Most of these Boolean parameters are true. Indicates that the event handler is called during the capture phase; Represents an event handler that is called during the bubbling phase.

<! DOCTYPE html>

because IE only supports event bubbling. So in most cases, the event handlers are added to the bubbling phase of the event stream to maximize compatibility with various browsers.

It is best to add an event handler to the capture phase only when it needs to be intercepted before the event arrives at the target. Assumptions are not particularly needed. It is not recommended to register event handlers during the event capture phase.





How to handle JS binding events and removing events

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.