Zero Progress Bar


#1


I want to set the data-max of my progress bar to zero but doing this causes the progress bar to count until infinity (100 divided by zero). How can I set my progress bar to zero?

Here is my HTML:

<progress class="progressbar" value="0" max="100" data-max="1"></progress>

I link to jquery and modernizr.

Here is my javascript:

    $(document).ready(function() {

      $('.progressbar').each(function() {
        var progressbar = $(this),
          progressbarValue = progressbar.next(),
          value = progressbar.data('min') || 0,
          max = progressbar.data('max'),
		 time = (100 / max) * 5,
          value = progressbar.val(),
          animate = setInterval(loading, time);

        function loading() {
          value += 1;
          progressbar.val(value);
          progressbarValue.html(value + '%');
          if (value == max) {
            clearInterval(animate);
          }
        };
      })
    });


#2

Wouldn't you just put the division and timer part in an if-statement?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.