我有这个表从数据库加载,所以所有元素each row都具有相同的属性.
<table class="table table-responsive">
<tr>
<th>Product name</th>
<th>Quantity</th>
<th>Price per unit</th>
<th>Total</th>
<th>Action</th>
</tr>
<tr>
<td class="product-name">Product one name</td>
<td class="product-quantity">
<!-- plus button should increase quantity and update total based on unit_price*quantity -->
<button class="btn"> +</button>
<input type="text" value="2"/>
<button class="btn"> -</button>
</td>
<td class="unit-price">50</td>
<td class="total-price">100</td>
<td>
<!-- this should delete entire row -->
<button class="product-delete">Delete</button>
</td>
</tr>
...
</table>
<!-- on each quantity change this needs to update -->
<div class="grand-total"> 5000 </div>
Run Code Online (Sandbox Code Playgroud)
我试图制作 …