+ 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
4 Respostas
+ 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.
+ 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
+ 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
+ 2
Both are good
😊😊