Closed wrabit closed 10 years ago
What exactly are you trying to achieve? There's probably a way to do it using countUp as it works now.
Ok, I added to the printValue function to achieve, not ideal and probably not the best written code but I thought I would post it incase others wanted to add the same functionality:
// Print value to target
this.printValue = function(value) {
var width = 3;
var result = (value) ? self.formatNumber(value) : '--';
// 1. make string
result = result + '';
// 2. add padding of four 0's
result = result.length >= 4 ? result : new Array(4 - result.length + 1).join('0') + result;
// 3. wrap digits with span tags
result = '<span>' + result.split('').join('<\/span><span>') + '<\/span>';
if (self.d.tagName == 'INPUT') {
this.d.value = result;
} else {
this.d.innerHTML = result;
}
}
Why do you need to put each digit in a span?
As the title says... "Wrapping individual digits in span or div tags" I am adding styling to the counter where I need fixed dimensions for each digit.
Oh - You need fixed dimensions for each digit - gotcha. You've got a good solution there.
Is this method still working?
Ok, I added to the printValue function to achieve, not ideal and probably not the best written code but I thought I would post it incase others wanted to add the same functionality:
// Print value to target this.printValue = function(value) { var width = 3; var result = (value) ? self.formatNumber(value) : '--'; // 1. make string result = result + ''; // 2. add padding of four 0's result = result.length >= 4 ? result : new Array(4 - result.length + 1).join('0') + result; // 3. wrap digits with span tags result = '<span>' + result.split('').join('<\/span><span>') + '<\/span>'; if (self.d.tagName == 'INPUT') { this.d.value = result; } else { this.d.innerHTML = result; } }
Is this possible?