addEventListener() method attaches an event handler to the specified element – it is supported in many browsers such as Google Chrome, Mozilla Firefox, Safari, Opera, and the latest versions of Internet Explorer.
element.addEventListener(event, function, useCapture)
event: Required parameter. Name of the event that is to be clicked. Data type is string.
function: Required parameter. The function is supposed to be executed when the
event is clicked.
functioncan be both internal and external functions.
useCapture: Optional parameter. A boolean value indicates whether the event handler is supposed to be executed in the bubbling or the capturing phase.
if true: capturing phase else: bubbling phase
View all Courses