var wan='<span class="main_div_p_span">万</span>';
var yi_='<span class="main_div_p_span">亿</span>';
var arr=123456789;
arr = arr.toString();
function yi(data){
var res='';
if(data.length >=9){
var a = data.substring(0,data.length-8);
var b = data.substring(data.length-8,data.length);
var r1 = a+yi_;
if(b.length>=5){
var c = b.substring(0,b.length-4);
var d = b.substring(b.length-4,b.length);
r1 = r1+c+wan+d;
res = r1
}
}else if(data.length>=5){
var c = data.substring(0,data.length-4);
var d = data.substring(data.length-4,data.length);
r2 = c+wan+d;
res = r2
}else{
res =data
}
return res
}
$('.main_div_p_3').html(yi(arr))
给随便一个字符串加单位
最新推荐文章于 2023-06-13 01:48:41 发布