+ 18
Why my loop does not work ?
I want this loop to work inside the <h3>, how could i do that ?! https://code.sololearn.com/W256rgje7B7h/?ref=app
7 Respostas
+ 11
Your script is loading before DOM is loaded. Wrap your JS code in onload function.
window.onload = function() {
// your JS code here
}
Also, you cannot incremented a HTML element using ++ in your loop. You might want to get the innerHTML value instead.
+ 7
<del>This question has been asked many times, please use search function, Bono</del>🤣😂🤣😂🤣😂🤣 kidding
A bit supplements to the answers above:
Sololearn js tab of web codes will be added to the end of head tag when compiled.
So it will run before the body.
There are several ways, either putting everything in window.onload as Hasty Rei has suggested, or scripting a function in js tab (head), and later call it in end of body tag as Emma has demo
A question that naturally arises is, which comes first?
This code by Calvin best demonstrates the sequence of loading:
https://code.sololearn.com/W8qiO41gHNfu/?ref=app
+ 3
https://code.sololearn.com/WuKbLT0vAp3d/?ref=app
+ 3
Wait this question was already answered
Thanks phone/sololearn glitch
+ 2
Hi, Bono!
I "played" a little with your counter.
See this: https://code.sololearn.com/Wuhz7RUEJkL6
0
"The limit exceeded"?