how to add leadingZero? [duplicate]

108
May 19, 2017, at 7:06 PM

This question already has an answer here:

  • is there a way to append leading zero's to an ordered number list? (01 or 001 as opposed to just 1) 3 answers
  • Javascript add leading zeroes to date 11 answers

im trying to get a leading zero on my counter. So that when it start it's displayed 00 -> 01 ... 03 -> 04 -> 05 ... 09 -> 11

$('.count').each(function() {    
   $(this).prop('Counter', 0).animate({
     Counter: $(this).text()
   }, {
     duration: 4000,
     easing: 'swing',
     step: function(now) {
       var time;
       time = leadingZeros(now);
       $(this).text(Math.ceil(time));
     }
   });    
});
function leadingZeros(num) {
  var time, number;
  time = parseInt(num);
  while (time < 9) {
    number = "0" + time;
  }
  return number;
};

in the html its just

<span class="count">53</span>

what am i doing wrong?

best regards

READ ALSO
Input typeahead throwing : typeahead is not a function

Input typeahead throwing : typeahead is not a function

I am working with Angular JS application, in which we have input field as typeaheadIt working fine, below is code of creating input field :

121
How to add div to text within dynamic nested div using jquery

How to add div to text within dynamic nested div using jquery

Below is the HTML format code for the nested div

55
Ember component multiple ajax calls

Ember component multiple ajax calls

I am very new to ember js 213

104
How to open new form on dynamic button click event in php

How to open new form on dynamic button click event in php

I have created dynamic button in phpi need to to open new form in same homepage on that dyanamic button click event and when i am clicking on button it refresh the page

85