+ 3

Onclick vs addEventListener

I was just wondering witch one is better to use? I was always told to use event listener. Does addEventListener have full support for all the browsers. Are there any other ways to interact with a browser using click besides these two? Thanks for your help in advance

16th Mar 2019, 3:07 PM
John Wick
4 Answers
+ 6
Both are good , but addEventListener is better when you have a bigger code and you want to add more events , because it will be easier to find and remove or change them.
17th Mar 2019, 12:14 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 4
Shudarshan Rai 👑 thanks that help someone once told me onclick was old school and not to use it wasn’t sure what was best in todays professional work
16th Mar 2019, 4:16 PM
John Wick
+ 2
//Both of them are best, actually addEventlistener was created for IE, although onClick is supported by all browser because of html events, You can always use both in your projects, although if you don't want inline script you can use addEventlistener else onclick is best
16th Mar 2019, 4:13 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
Both are good 😊😊
18th Mar 2019, 9:25 AM
Alpha
Alpha - avatar