我遇到了一些问题,看起来应该很容易处理JQuery。基本上我在我的页面上有一张桌子。表格中的每一行都有一个复选框和一个单元格。我正在尝试编写一个遍历每行的函数,并检查该复选框是否被选中。如果是这样,它会将金额加到我的总额中,以便我可以将其显示在我的页面底部。出于某种原因,我无法找到我的复选框。以下是页面上的html。找到单个jquery后裔
<div class="BillAccordian">
<h3><A href="#">Past Due Bills - Total $ 1047.62 </A></h3>
<div>
<table style="background-color:Red">
<tr>
<td>
<input class="RowSelector" id="BillInfo_PastDueBills_0__Selected" name="BillInfo.PastDueBills[0].Selected" type="checkbox" value="true" />
<input name="BillInfo.PastDueBills[0].Selected" type="hidden" value="false" />
</td>
<td>
RE
</td>
<td>
334
</td>
<td>
1047.62
</td>
<td>
Bill Number 20121
</td>
</tr>
</table>
</div>
</div>
这里是我使用的是现在要努力完成的jQuery脚本这个
$('input.RowSelector').click(function() {
var sum = 0;
alert("1");
// we want to sum up the values of all input.sum elements that are in the same tr
// as this one
$('tr').each(function (e) {
var val;
alert($(this).find(".RowSelector")[0].is(':checked'));
if ($(this).closest("input.RowSelector").val() == true) {
alert("3");
// val = parsefloat($(i).find(".BillAmount").val());
//
// if (isNaN(val) || val === undefined) {
// return;
}
// sum += val;
});
// $(this).find('#SelectedTotal').val(formatDollar(sum));
});
});
很多它是现在监守我只是tyring获得选择的保持注释掉我需要继续。在函数中使用警报我什么也得不到。我认为它不喜欢我所追求的[0],但用它找到没有找到的东西。我确实检查了我的$ this.html以确保我有正确的元素,并且它确实返回了整个表格行中的复选框,所以我很困惑这一点。有人能告诉我我错过了什么吗?
感谢