////////////////////////// HTML
/////////// INR Format JS
////// Result - 30,67,89,948.26
//////////////// Other formate JS
/////////Result- 306,789,948.26
<span id="counterLbl" class="count">306789948.26</span>
/////////// INR Format JS
function Count_Running() {
$('.count').each(function
() {
$(this).prop('Counter',
0).animate({
Counter: $(this).text()
}, {
duration: 4000,
easing: 'swing',
step: function (rnCnt) {
var va = INR_RunningCnt_Format(rnCnt);
$(this).text(va);
}
});
});
}
function INR_RunningCnt_Format(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
var z = 0;
var len = String(x1).length;
var
num = parseInt((len / 2) - 1);
while (rgx.test(x1)) {
if (z > 0) {
x1 =
x1.replace(rgx, '$1' + ',' + '$2');
}
else {
x1 =
x1.replace(rgx, '$1' + ',' + '$2');
rgx =
/(\d+)(\d{2})/;
}
z++;
num--;
if
(num == 0) {
break;
}
}
return x1 + x2;
}
////// Result - 30,67,89,948.26
//////////////// Other formate JS
function Count_Running() {
$('.count').each(function () {
$(this).prop('Counter', 0).animate({
Counter: $(this).text()
}, {
duration: 4000,
easing: 'swing',
step: function (now) {
var va = Other_Format(now);
$(this).text(va);
}
});
});
}
function Other_Format(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
No comments:
Post a Comment