我試圖在表中使用jQuery將一列中的值加起來。爲了實現這一點,我首先試圖找到每一行的第一個單元格,然後將它們添加在一起,然後將此值放入輸入字段中。jQuery:對於每一行第一個單元格
這樣做的最好方法是什麼?
到目前爲止,我有:
// for each row
$('table tbody tr').each(function() {
$firstCell = $(this).index(1).find('input').val();
});
所以我需要添加的第一個單元在一起的每一行。所以基本上是每個創建的$ firstCell變量的實例。例如
$('output').val(parseInt($firstCell.val()) + parseInt($firstCell.val()));
任何人都可以指向正確的方向嗎?
感謝
http://stackoverflow.com/questions/6155293/select-第一,TD-中,每行-W-的jQuery – ygesher 2013-10-04 11:22:42