element.onload vs element.addEventListener("load",callbak,false)

VinnyD picture VinnyD · Aug 1, 2011 · Viewed 25.3k times · Source

What's the difference between addEventListener and onclick?

var h = document.getElementById("a");
h.onclick = dothing1;
h.addEventListener("click", dothing2);

The code above resides together in a separate .js file, and they both work perfectly.

Answer