+ 2

Whats the usefullness Of AddEventlistener In Javascript(Please Need A Detailed Explanation)

A javascript function addeventlistener() usee.

18th Feb 2019, 6:53 PM
Olajide Oladapo Ayomide
Olajide Oladapo Ayomide - avatar
1 ответ
+ 3
Any element in html can send/receive some actions (events). At example every element can receive an event when you click on them, mouse leave them etc... For "listen" these events, you have two alternative (usually): use the event on the element like attribute or use addEventListener... While the first is easier to work with, is limited because you have less control on how the browser can handle the relative event. Futhermore not all events are handable in this way. Using addEventListener give you more control on how handle the event (at example in which phase you want capture it) and allow you to listen to all events
18th Feb 2019, 7:51 PM
KrOW
KrOW - avatar