如下图,怎么在网页中展示?数字是动态的,求指教,感谢
首先将数字转换为带有百分位分割的字符串
function toThousands(num) {
var num = (num || 0).toString(), re = /\d{3}$/, result = '';
while ( re.test(num) ) {
result = RegExp.lastMatch + result;
if (num !== RegExp.lastMatch) {
result = ',' + result;
num = RegExp.leftContext;
} else {
num = '';
break;
}
}
if (num) { result = num + result; }
return result;
}
然后将1替换为
<image scr='1.jpg' />
2替换为
<image scr='2.jpg' />
...
都好替换为
<image scr='coma.jpg' />
事先准备好0 1 2 3 4 5 6 ... , 这些图片。
将这些标签再装入一个蓝色背景的div
另外,逗号也可以不用图片,而是用蓝色的文字。