+ 2
Hello! Why I can't use here in Sololearn sandbox JavaScript method "addEventListener"
addEventListener bug https://code.sololearn.com/Wo2yP85pyXoi/?ref=app
2 Respostas
+ 8
It does only that you need to add window.onload = function(){
//code goes here
}
Like in this code:
https://code.sololearn.com/Wj153VKGavW0/?ref=app
+ 5
Javascript needs all html dom elements loaded before doing something with them. Enclosing your code like this:
window.onload = function() {
// your original javascript code
}
It means, when all html elements are created and loaded in my browser, I could reference them (adding event listeners, etc...)