更新时间:2023-12-05 12:20:16
首先,如果重复此行,则应在按钮上使用一个类,而不要使用id
,因为重复的id属性无效.
Firstly, if this row is repeated you should use a class on the button, not an id
, as duplicate id properties are invalid.
<tr id="product-id-<?=$product->product->id;?>">
<td><span class="product_price_show"></span></td>
<td><span><?= $product->product_qty; ?></span></td>
<td><span><?= $product->product->stock->qty; ?></span></td>
<td><span><?= $product->total_price_tax_incl; ?></span></td>
<td>
<a class="quick-update-order-product">Update</a>
</td>
</tr>
按钮上有课程后,您就可以使用closest()
查找tr
:
Once you've got the class on the button you can use closest()
to find the tr
:
$('.quick-update-order-product').click(function() {
var trId = $(this).closest('tr').prop('id');
});