+ 1

Can someone please check my javascript code? It is not working and I can’t figure out why..

This is my code: https://code.sololearn.com/WLbRocg4KTJp/?ref=app

3rd Nov 2018, 8:22 PM
Brian Bawuah
Brian Bawuah - avatar
2 ответов
+ 7
Brian Bawuah, The reason why your code acts like that is because the DOM is executed before the JavaScript. You need to make sure the JavaScript executes before the DOM. Therefore you need to add window.onload event. Second is you did not wrote the event listener correct. It is addEventListener instead of eventListener. Have a look at the changes, hope it helps👍 https://code.sololearn.com/WaeCNY58Y56Z/?ref=app
3rd Nov 2018, 8:29 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 2
It's easier to define the function by onclick keyword: <button onclick="myfunc()">
3rd Nov 2018, 8:45 PM
Микола Федосєєв
Микола Федосєєв - avatar