我試圖讓這個jQuery數學與我的表單工作,我得到的代碼段工作正常,但是當轉移到所需的形式,我不能讓它對齊運行所需的數學。Jquery表格計算不對齊
任何指向我出錯的地方。
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<script>
jQuery(function($) {
$(".Qty1, .TradePrice1").change(function() {
var total = 0;
$(".Qty1").each(function() {
var self = $(this),
TradePrice1 = self.next(".TradePrice1"),
subtotal = parseInt(self.val(), 10) * parseFloat(TradePrice1.val(), 10);
total += (subtotal || 0);
});
$("#total1").val(total);
});
});
</script>
<tr>
<th><div align="center">
<input type='text' name='F01u1' id='F01u1' />
</th>
<td>
<input type='text' name='Model1' id='Model1' />
</td>
<td>
<input type='text' name='Description1' id='Description1' />
</td>
<td>
<input type="text" name='TradePrice1' id='TradePrice1' />
</td>
<th>
<input type="text" name='Qty1' id='Qty1' />
</th>
<td>
<input type='text' name='Total1' id='Total1' />
</div></td>
</tr>
如果您希望我們幫助您,請提供一個帶代碼的JS鏈接(包括CSS,如果您討論對齊...) – Aeldred
刪除您的表格元素之間的那個狡猾的div標籤作爲開始。 - 你可能需要進一步解釋你的意思是什麼「但是當轉移到所需的形式我不能讓它對齊運行所需的數學」..... – Stuart
我已經把一個jsBin和整理了標籤爲你https://jsbin.com/hihoyilobu/edit?html,js,output –