The difference between Dom AddEventListener and ID binding events

Source: Internet
Author: User

There is a write in the document.

//the AddEventListener () method is used to add an event handle to the specified element. //tip: Use the RemoveEventListener () method to remove the event handle added by the AddEventListener () method. //Internet Explorer 8 and earlier versions of IE do not support the AddEventListener () method, and Opera 7.0 and opera earlier are not supported. However, for browsers that do not support this function, you can use the Attachevent () method to add an event handle (see "More instances" for a cross-browser solution). //GrammarElement.addeventlistener (Event,function, Usecapture) event must be. A string that specifies the event name. Note: Do not useThe "on" prefix. For example, use "click" instead of "onclick". Tip: All HTML DOM events can be viewed in our full HTML DOM event object reference Manual. functionmust be. Specifies the function to execute when the event is triggered. When the event object is passed into the function as the first argument. The type of event object depends on the specific event. For example,"Click"The event belongs to the MouseEvent (mouse event) object. Usecapture is optional. A Boolean value that specifies whether the event is executed during the capture or bubbling phase. Possible values:true-event handles are executed during the capture phasefalse-falseDefault Event handles are executed during the bubbling phase

We can bind multiple events or multiple identical events for an ID, and will not overwrite the jquery binding event, which overrides the former.

The difference between Dom AddEventListener and ID binding 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.