0

Could you help me? I need to know what happens in this example to not use onclick in html

https://code.sololearn.com/WWCUPPTHa7bt/?ref=app

1st Dec 2020, 4:28 PM
Geovanny GonzĂĄlez
Geovanny GonzĂĄlez - avatar
3 Answers
+ 7
Use it . window.onload=function(){ var muestra = document.querySelector(".boton"); muestra.addEventListener("click", function(){ alert("bien hecho"); }); }
1st Dec 2020, 4:31 PM
TOLUENE
TOLUENE - avatar
0
Excellent! Thanks a lot.
1st Dec 2020, 5:39 PM
Geovanny GonzĂĄlez
Geovanny GonzĂĄlez - avatar
0
it's better this way, right? window.addEventListener("load", function(){ var muestra = document.querySelector(".boton"); muestra.addEventListener("click", function(){ alert("bien hecho"); }); });
1st Dec 2020, 6:30 PM
Geovanny GonzĂĄlez
Geovanny GonzĂĄlez - avatar