hello,
this source should activate 3 counters from 00000 to 00123, to 00456 and to 00789
my problem is I dont know how to use padStart because I would like to have the counters output always with 5 digits. I was trying various things but nothing worked. exapmle:
countValue = (countValue.padStart(5, ‘0’));
It would be great if someone could helped me out
thx
You aren’t showing how you’re using it, but I suspect you’re trying to apply the function to a number, and padStart is for strings. numbers don’t have padding (that wouldn’t make sense – 00000 is 0, 00123 is 123), the concept is only relevant when they are strings (it’s visual formatting)
For the sake of simplicity, I left out style. You can copy the source into your environment and test it. The 3 counters are displayed in a div element but unfortunately only three digits. So e.g. if the counter counts up to 500 I would like to see 00500 displayed. Unfortunately I don’t know how to solve this problem and I hope for your help
No, you’ve left out the code that shows where you’re trying to use padStart. I assume you are using it on the line where you define the variable countStart. countStart is a number. As I said in my reply you can’t pad numbers, that makes no sense. It needs to be a string
…It accepts two arguments (now and fx), and this is set to the DOM element being animated.
now: the numeric value of the property being animated at each step
fx: a reference to the jQuery.fx prototype object, which contains a number of properties such as elem for the animated element, start and end for the first and last value of the animated property, respectively, and prop for the property being animated.
Didn’t check but that does seem to suggest countValue would be a number and not a string.