Add event listener using Javascript problem | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Add event listener using Javascript problem

I'm trying to use addEventListener function but I'm having the problem that the page is not fully loaded yet so it can't find the invoked html tags. Is using <body onload="funct()"> the only solution?

13th Oct 2018, 5:23 PM
Parsa Gholipout
Parsa Gholipout - avatar
3 Antworten
13th Oct 2018, 6:20 PM
Burey
Burey - avatar
+ 3
no, you can put your script at the bottom of the body tag using the script tag <script>here</script> saves all the confusion with having to put eveything inside the window.onload = function
13th Oct 2018, 7:37 PM
D_Stark
D_Stark - avatar
+ 2
in your JavaScript you can also use: window.onload = funct;
13th Oct 2018, 5:28 PM
Ulisses Cruz
Ulisses Cruz - avatar