Home › Forums › JavaScript › Add '0' before single digit numbers jQuery? › Reply To: Add '0' before single digit numbers jQuery?
August 19, 2013 at 2:49 am
#147330
Participant
Hi, i made in this way:
$('.box').click(function () {
$(this).text(function (i, n) {
var result = Number(n) + 1;
if ( result < 10 ) {
return "0" + result;
} else {
return result;
}
});
});
@Rugg where I can read about this variant of counting :
$(this).text(function (i, n) {
return Number(n) + 1;
});
Thanks.