我有一个如下所示的表格:
<table class="authors-list">
<tr>
<td style="font-size:10px;"><a class="deleteRow"> <img src="delete2.png" /></a></td>
<td ><input type="text" id="product1" name="product1" class="rounded"/></td>
<td ><input type="text" size='5' id="qty1" name="qty1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h09_1" name="h09_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h12_1" name="h12_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h15_1" name="h15_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h18_1" name="h18_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h21_1" name="h21_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h24_1" name="h24_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h27_1" name="h27_1" class="rounded"/></td>
<td class="tdcheckbox"><input type="checkbox" id="h30_1" name="h30_1" class="rounded"/></td>
<td><input type="hidden" name="checkedsizes_1" id="checkedsizes_1" value="0"></td>
</tr>
</table>
我想要一个脚本,当调用用该行checksizes
中选中复选框的数量填充每个行字段时。
小提琴可以在这里查看:http: //jsfiddle.net/emL6x/8/
我到目前为止的jquery是:
countChecks(){
$('.author-list tr').each(function(){
var count = 0;
var hdn = $(this).find('input[name^="checkedsizes"]');
count = $(this).find(':checkbox:checked').length;
hdn.val(count);
});
}
这目前不起作用。感谢您对答案或小提琴的任何帮助。我正在使用 jquery 1.9.1。
请记住,我的表有多行,因此需要遍历每一行。
再次感谢。