Which method is used to attach an event listener to a DOM element?

JavaScript Associate Easy

JavaScript Associate — Easy

Which method is used to attach an event listener to a DOM element?

Key points

  • addEventListener() is the standard method for attaching event listeners in modern JavaScript.
  • attachEvent() is an outdated method used in older versions of Internet Explorer.
  • bindEvent() and onEvent() are not valid methods for attaching event listeners in JavaScript.

Ready to go further?

Related questions