【发布时间】:2020-06-30 08:50:18
【问题描述】:
我有一个表格来显示动态列表中的对象元素,因此表格应该能够按照用户认为合适的方式增长和缩小。我如何才能获得特定的行索引?
我基本上有一个购物车,上面有价格、数量、名称等。最后是一个删除按钮,单击该按钮应删除当前行。所以我需要能够将当前列表元素与其各自的删除按钮相关联。
下面是我的桌子:
<div class="customContainer">
<table class="customTable">
<thead class="customHead">
<tr class="customRow">
<th class="customHead2">Product</th>
<th class="customHead2">Quantity</th>
<th class="customHead2">Price</th>
<th class="customHead2">Total</th>
<th class="customHead2">Remove</th>
</tr>
</thead>
<tbody class="customBody">
@foreach (var itemList in Model)
{
<tr class="customRow">
<td class="customData">@itemList.Name</td>
<td class="customData">@itemList.Quantity</td>
<td class="customData">@itemList.Price</td>
<td class="customData">@itemList.Total</td>
<td class="customData"><button class="btn-dark">Delete</button></td>
</tr>
}
</tbody>
</table>
</div>
有没有办法给删除按钮 'btn-dark' 一个动态 id,随着表格的增长/缩小而增加/减少?
【问题讨论】:
标签: javascript c# html asp.net-mvc