Goodnight! I have such a block of code:

// Вывод процентов, вида 99.99%, на поле прогресс бара! var myPer = 0; $("#progressbar").progressbar({ value: myPer }).children('.ui-progressbar-value').html(myPer.toPrecision(3) + '%').css({ display: 'block', align: 'center', fontColor: 'red', }); 

This block of code displays 0.00% on ProgressBar. Task - I need to add 0.01% + 0.00% every 8640ms until the total amount equals 100.00%. Help, please, solve the problem, but by the night the brain no longer works, unfortunately ;-( Using the .animate () method, but not necessarily ...

  • Please help solve the problem. - spoilt


2 answers 2

It can be like this , for example ... well, just change 1000 to 8640 ...

 <div class="progress"></div> 

-

 var val = 0.00; $('.progress').progressbar({value: val }); function updateProgress() { val += 0.01; $('.progress') .progressbar({value:val}) .children('.ui-progressbar-value') .html(val.toFixed(2) + '%') .css({ display: 'block', align: 'center', fontColor: 'red', }); if(val < 100) setTimeout(updateProgress, 1000); } setTimeout(updateProgress, 1000); ​ 

Go

  • Thank you so much, you helped me a lot! - spoil

You can also do the same, just change setTimeout to setInterval and not forget about clearInterval

And about $().animate() - read about css3 transitions, it's a lot cooler