标签:document hang var fun htm lis integer string for
js thousand seprator and change TD content // integer function addCommas(n){ var rx= /(\d+)(\d{3})/; return String(n).replace(/^\d+/, function(w){ while(rx.test(w)){ w= w.replace(rx, ‘$1,$2‘); } return w; }); } //decimal function thousandBitSeparator(num) { return num && num .toString() .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) { return $1 + ","; }); } // change table td content by getElementsByClassName() function changeTDcontent(){ var olist=document.getElementsByClassName("cl_id"); for(var i=0;i<olist.length;i++){ var c=olist[i].innerHTML; olist[i].innerHTML=addCommas(c); } }
js thousand separator and change td content
标签:document hang var fun htm lis integer string for
原文地址:http://www.cnblogs.com/rojas/p/7774123.html