<div class="codetitle"> <span><a style="CURSOR: pointer" data="58318" class="copybut" id="copybut58318" onclick="doCopy('code58318')"><u>複製程式碼</u></a></span>程式碼如下:</div> <div class="codebody" id="code58318"> <br><script type="text/javascript"><BR> varvar 格式= function (number, form) {<BR> var forms = form.split('.'), number = '' number,numbers = number.split('.')<BR> , split('')<BR> , exec = function (lastMatch) {<BR> == if (leftnumber.length) {<BR> return leftnumber.pop();<BR> } else if (lastMatch == '0') {<BR> } else {<BR> 🎜> } else {<BR> return lastMatch;<BR> ).reverse().join('').replace( /. /g, exec).split('').reverse().join('');<BR> string = leftnumber.join('') string;<BR><BR> if (forms[1] && 形式[1].length) {<BR> leftnumber = (numbers[1] &&numbers[1].length) ?數字[1].split('').reverse() : [];<> ' forms[1].replace(/./g, exec);<BR> }<br> return string.replace(//.$/, '');<br>};<BR>alert(format(123 ) ) , '#.00')) // // 輸出 123.00 < // 輸出 123 <br>alert(format(123, '0) 000.00') ) // 輸出0123.00 <br>alert(format(123456, '###,###.00')) // 輸出 // 輸出 </script> </div>