+ 12
Why this code is not working on sololearn?
This code is working in browser, but not in sololearn. Can someone tell me why is this not working here? https://code.sololearn.com/W5az50InWO57/?ref=app
4 Réponses
+ 6
Hey buddy! Your problem is solved.
When you write the Javascript code in the JS section, Sololearn first executes the javascript section, and then loads the HTML and CSS files.
If you want your javascript code run hand in hand with html, then you need to write the code in html itself.
<body>
..
..
<script>
...
</script>
</body>
Put the javascript code inside script tags, and keep the layout as I said. Script should come at the end of the body.
Happy coding <^_^>
+ 6
Thanks to all😇
+ 4
As Rei said add window.onload event
https://code.sololearn.com/WBkCB6Z7DS67/?ref=app
+ 3
because its executed before the page load.
we usually use window load event, because the script will be injected later in html.