javascript - jQuery Is not a number -
I have a table that uses yoga values when I write something which is not a number, then I How to keep the result 0?
Some code:
$ (document) .on ('keyup', 'input', newSum); Function newSum () {var sum = 0; Var thisRow = $ (this) .closest ('tr'); Var Total = 0; $ (ThisRow) .Find ("TD: No (gross) input"). Each (function () {sum + = parseInt (this.value);}); // Entrymos El Color de la Sima de Cad file if ((amount% 2 == 0)) $ $ (thisRow) .find ('total'). Chetan ({backgroundColor: 'green'}, 1000);} and {$ (thisRow) .find ('(' background ':' red '}, 1000);} $ (thisRow). Fed ("total") Html (sum); $ ('total') .Every (function () {total + = parseint ($ (this) .html ());})}}
Thanks in advance.
Try: sum + = + this .value || 0; + tries to put the value of a number into the box, if that value fails Is 0
Comments
Post a Comment