1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Zero Progress Bar

Discussion in 'jQuery' started by makamo66, Oct 5, 2016.

  1. #1
    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);
    }
    };
    })
    });
     
    makamo66, Oct 5, 2016 IP
  2. Einheijar

    Einheijar Well-Known Member

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    165
    #2
    Seems like all you need to do is reset value to 0, check your form in chrome/firebug to see if the value dynamically updated. Also using code tags would be immeasurably appreciated by those who you wish to ask for help from.
     
    Einheijar, Oct 5, 2016 IP