0
Please help... What am i doing wrong in this code?
4 Respostas
+ 5
1. Put all your js inside a window.onload=function(){
//your js
}
2. It is not click, it is "click".
3. At line 24, replace display with width
+ 3
If you use document.getElementById("progress") instead of el, the code works.
function click() {
//var el = document.getElementById("progress");
var neWidth = 15;
var id = setInterval(frame, 50);
function frame() {
if (neWidth <= 100) {
neWidth++;}
else{
clearInterval(id);
}
document.getElementById("progress").style.width = neWidth + "%";
document.getElementById("progress").innerHTML= neWidth + "%";
}
}
I also replaced a }, because you put the 2 document.getElement... inside the else{}
+ 3
Works perfectly now... Thumbs up man...
0
Thanks Alex, but its not still working in my playground.
1. Btw how possible is it that i couldnt use document.getElementById('progress') as a stored variable.
2. The errors i keep getting most is that Javascript can't read property of null... Meaning couldnt get my ID..
3. I also tried using the addEventListener method but still getting the same error.
4. The only time i get it to run, it did so automatically as soon as i refreshed the browser... Meaning that the click function didnt do anything...
Please help me out... 😭😭😭😭