<script type="text/javascript">
$(document).ready(function () {
$("tr.item").each(function () {
var weight = $(this).children('td.Weight').text();
var unit = "Kg";
$(".Weight").text(weight + unit);
});
});
</script>
html code...
@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>
</tr>
这些值继续与它们自己连接,例如:5000Kg,然后是 5000KgKg,然后是 5000KgKgKg 等等。我无法考虑当前值,代码会考虑所有行。