Ich mache eine Berechnung und das Ergebnis von dieser Operation geht in einen Eingabetext, oft kommt das Ergebnis in Tausenden und ich möchte sie mit einem "," zum Beispiel nicht enthalten 100000 muss es 100.000 zeigen, aber ich kann nichts finden, was zu meinem Projekt passt, hat jemand eine Idee?Eingabe Text formatieren, die Ergebnis von Berechnung erhalten
//Here I do the math
function calcular_total() {
importe_total = 0
var totalC = 0
$("#table1 #tb1 .item").each(function(){
var ku1 = $(this).find('.precio').text().replace('$', '');
var ku2 = $(this).find('.importe .imp').val();
totalC += ku1*ku2;
});
$("#total").val(totalC.toFixed(2));
}
//The result goes here
<label style="font-family: 'Raleway', sans-serif;" for="total">Total: </label> <span class="currencyinput">$<input type="text" id="total" name="total" value="0" readonly/></span>
'$ :) (“ #total "). val (totalC.toFixed (2) .toLocaleString (" de "))' – Akam
http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in -javascript – sinisake
Mögliches Duplikat von [So drucken Sie eine Zahl mit Kommas als Tausendertrennzeichen in JavaScript] (http://stackoverflow.com/questions/2901102/how-to- print-a-number-with-commas-as-tausends-separators-in-javascript) – Bijan