0
I’m trying to set up a charging bar that starts after 2 seconds of loading the document
, Her every 100
thousandths of a second win 1%
of width
. However, when the page loads, console.log() shows that the function is running, but nothing happens. How can I fix the problem ?
$(document).ready(function(){
setTimeout(function(){
var count = 0;
while(count < 100){
setTimeout(function(){
$("#loader-progress").css({"width":count + "%"})
},500)
count++;
}
},2000);
});
Voce can use
debugger;
, inside your while, open your browser Devtools and see the pq is crashing. =)– andrepaulo
but it hangs the page, not allowing you to open devtools
– Murilo Melo
leaves devTolls open, before calling the page =)
– andrepaulo
tries to put Count++ just below while and multiply the 100 of the timeout by Count (100*Count), I think it will work...
– JuniorNunes
put Count++ below while and stopped crashing, but no errors appear yet, edited question :D
– Murilo Melo
I tried to multiply Count in timeout but it didn’t work
– Murilo Melo
And how is the CSS of your Loader-Progress? If Voce increase manual width, it is increasing?
– Aline
manually works
– Murilo Melo
@Withilogambôa what you have to multiply is the delay of the timeout, in which case it would be 500*Count:
setTimeout(function(){
 $("#loader-progress").css({"width":count + "%"})
 },500*count)
– JuniorNunes
yes @Juniornunes, I understood, however, it did not run
– Murilo Melo