Get data from the background. If the data is "4", the front desk will display "04". If the background is "04", the front desk will display "04"
My code:
$(".ball_1").html(data.ball_1>=10||data.ball_1.length=3data.ball_1:'0' data.bal_1||data.ball_1.substring (1));
Report an error directly
$(".ball_1").html(data.ball_1>=10?data.ball_1:'0' data.ball_1&&data.ball_1.length>=3?data.ball_1.substring(1)?data.ball_1 );
If the data is "4", it will display 4. How should this function be implemented?
For example
"1" => "01"
"4" => "04"
"99" => "99"
Use slices
This can do what you need:
pad zeros for one digit
andretain only two digits for three digits
var num = '1';
num = num<10? '0'+num : num;
//What does it mean to keep two digits in a three-digit number? ? ? ?
//num = (num==100 || num>100)? ... : ...
parseInt('04')<10?'0'+parseInt('04'):'04'