I am trying to make a progress bar with css loading when loading images. For this, I use the following script:
<html> <head> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"/> <script type="text/javascript"> var n=0; var c=0; $('img').each(function() { n++; var tmpImg = new Image() ; tmpImg.src = $(this).attr('src') ; tmpImg.onload = function() { c++; }; }); var interval = setInterval(function() { percent = n/100; loaded = c/percent; </script> </head> <body> <div class="progress progress-info progress-striped active"> <div class="bar" id='fabbar' style="width: 20%"></div> </div>
But this does not work, i.e. progress bar is not progressing. How can i do this?
source share