**HTML Snippet**
<table id="mytable">
@foreach (var item in Model) {
<tr class="item">
<td>
@Html.DisplayFor(modelItem => item.OrderId)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerId)
</td>
<td>
@Html.DisplayFor(modelItem => item.OrderDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.OrderQty)
</td>
<td class="Weight">
@Html.DisplayFor(ModelItem => item.TotalWeight, new { id="TotalWeight"})
</td>
<td>
@Html.DisplayFor(modelItem => item.LimeType.LimeTypeName)
</td>
</tr>
</table>
<script type="text/javascript">
$(document).ready(function () {
$("tr.item").each(function () {
var weight = $(this).find(td[5].val());
var unit = "Kg";
var value = weight + unit;
$("#TotalWeight").val(value);
});
});
</script>
}
html as in markup
<tbody>
<tr>
<tr class="item">
<td> 1 </td>
<td> C001 </td>
<td> 7/26/2013 12:00:00 AM </td>
<td> 100.00 </td>
<td class="Weight"> 5000.00 </td>
<td> Hydrated Lime Powder </td>
<td> Order Pending </td>
<td>
</tr>
</tbody>
我想将 Kg 添加到我的 TotalWeight 值。我的代码不起作用。它将 Quantity1 中的值显示为未定义。如何在 jQuery 中访问表格?我忘了定义重量,但代码仍然不起作用,我已经发布了 html 标记