var subtotal = $(input [name ='subtotal []'])。eq(index).val(); var totalAmount = $(#sum)。val(); if(!isNaN(小计&&(小计))) { if(totalAmount> subtotal){ $(input [name ='subtotal []'])。eq(index).addClass ('changeShape'); } else { $(input [name ='subtotal []'])。eq(index).removeClass('changeShape '); } } }); } 解决方案 (input [name ='subtotal []'])。each(function(index){ var subtotal = (input [name ='subtotal []'])。eq(index).val(); var totalAmount = (#sum)。val(); if(!isNaN(subtotal&&) (小计))) { if(totalAmount> subtotal){ i have a text boxes that is dynamically created i want to compare the value of the textboxes to a textbox that sums the values in the dynamically generated textbexesWhat I have tried:function compareVals() {var subtotal = 0;var sum = 0;$("input[name='subtotal[]']").each(function (index) { var subtotal = $("input[name='subtotal[]']").eq(index).val();var totalAmount = $("#sum").val();if(!isNaN(subtotal && (subtotal))){if(totalAmount > subtotal) {$("input[name='subtotal[]']").eq(index).addClass('changeShape');}else {$("input[name='subtotal[]']").eq(index).removeClass('changeShape');}}});} 解决方案 ("input[name='subtotal[]']").each(function (index) { var subtotal =("input[name='subtotal[]']").eq(index).val();var totalAmount =("#sum").val();if(!isNaN(subtotal && (subtotal))){if(totalAmount > subtotal) { 这篇关于如何比较动态生成的文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 01:05