This content originally appeared on DEV Community and was authored by Gaurav-Shekhawat
so, this is different from previous posts. The past week was the first week of me posting any article on the web. Even after not writing everything in detailed form, the response I got was beyond my expectations. From now on, I will try my best to cover everything in detail..
addEventListener('click', ....)
and .onclick
are not the same
Yes, they are not the same. The difference being that in the addEventListener
, we can add multiple listeners to the same event. While the onclick
"overrides" the previous onclick
attached to the same event.
For example:- see the below codepen
Please open the above through "edit in codepen" and then see the outputs in the console. I have added enough comments to make you understand everything. In case of any doubt, please do comment.
The full reference about the above point can be found at Medium.
This content originally appeared on DEV Community and was authored by Gaurav-Shekhawat
Gaurav-Shekhawat | Sciencx (2021-08-22T06:38:13+00:00) Day 9 : Quick look at some JS points you may have missed. Retrieved from https://www.scien.cx/2021/08/22/day-9-quick-look-at-some-js-points-you-may-have-missed/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.