I want to set the data-max of my progress bar to zero but doing this causes the progress bar to count 'til 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);
- }
- };
- })
- });