Onclick vs addEventListener | Sololearn: Learn to code for FREE!


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

3/16/2019 3:07:58 PM

John Wick

4 Answers

New Answer


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.


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


//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


Both are good ๐Ÿ˜Š๐Ÿ˜Š