-2
私は、(128879)から(128,879)のような表の値を書式設定する作業中のプロジェクトで作業しています。私がこれまで使用してきたコードは次のとおりです。何千もの区切りのカンマを含む数値の書式設定
$(document).ready(function(){
$('#tableOne tr td:nth-child(3)').each(function(){
var num = $(this).text;
num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}); });
また、私はjQueryのNumberFormatter
ライブラリを試してみましたが、エラーコードはjQueryのは、(Chromeを使用してデバッガのページ上のコードの最後の行)で定義されていないことを示すと数学.js(運がない)。なぜこれが起こっているのか分かりません。 jQueryとMath.jsに使用
<script>
タグを以下に示します。
<script type = 'text/javascript' src ="jquery.numberformatter-1.2.4.min.js"></script>
<script type="text/javascript" src="math.js"></script>
'num.toString()。replace(' ... ');'それ自体は実際には何も更新しません。これはおそらく '$(this).text = num.toString()。replace(' ... ');'です。 – Xufox
[Replace method does not work]の重複の可能性があります(http://stackoverflow.com/questions/1433212/replace-method-doesnt-work) – Xufox