0
I don't understand why my Event Listener isn't working
This Is A Unit Converter ( Feet Into inches) I'm Adding A EventListener but I'm facing a bug so plz help me to fix it.. https://code.sololearn.com/W1N1ifyaeanF/?ref=app
3 Answers
+ 7
Thera some small changes .
and one main thing is how Sololern works ..
The thing you write in js tab gets placed in head tag while executing your code .
so you need to query DOM after page loads .
https://code.sololearn.com/W6HsEZIs8ZVY/?ref=app
+ 2
Javascript code is executed before the document is fully loaded. This triggers error because you are referencing an element that doesn't yet exist, browser has not finished rendering the content.
Javascript in this đ code works because the script block is placed after the body content, so the elements are there, ready for you to use : )
Window.onload = () =>
{
your js code goes here
...
}