Ich habe diese jquery Schleife:jQuery ändern Null Into Zero Mit schlug fehl, wenn
var total_value = 0;
$("select.dropdown").each(function() {
if (($(this).val()) = null) {
$(this).val() = 0;
}
alert ($(this).val());
total_value = parseInt(total_value) + parseInt($(this).val());
});
einige $(this).val()
noch null
Wert haben, weil Benutzer noch nicht ausgewählt haben. aber ich muss alle Werte summieren. Also, ich muss null
in 0
konvertieren, um berechnet zu werden.
aber ich kann es nicht warnen, weil dort IF
dort ist. Was ist daran falsch? IF
?
'$ (this) .val (0)' – Tushar
die Bedingung sollte sein if ($ (dies) .val() == null) –