jquery删除table 的tr
jquery删除table 的tr
html代码如下
<table class="ncsc-default-table order" id="texpress1">
<tbody nc_type="expresslist">
<tr id="shipping22">
<td class="bdl">汇通快递(HTKY)</td>
<td class="bdl">71262336499351</td>
<td class="bdl gray">
《芳华》 × 1<br>
</td>
<td class="bdl bdr tc"><a nc_type="edit" shippingid="22" orderid="24" href="javascript:void(0);" class="ncbtn ncbtn-bluejeansjeans"> 编辑</a></td>
</tr>
<tr id="shipping30">
<td class="bdl">包裹平邮(HTKY)</td>
<td class="bdl">71262334498890</td>
<td class="bdl gray">
《芳华》 × 1<br>
</td>
<td class="bdl bdr tc"><a nc_type="edit" shippingid="30" orderid="24" href="javascript:void(0);" class="ncbtn ncbtn-bluejeansjeans"> 编辑</a></td>
</tr>
</tbody>
</table>
js代码如下
function add_one(express_name, shippingcode, shippingid, goods_string){
var _html = '<tr id="shipping' + shippingid + '">\n' +
' <td class="bdl">' + express_name + '</td>\n'+
' <td class="bdl">'+ shippingcode + '</td>\n'+
' <td class="bdl gray">' + goods_string + '</td>\n'+
' <td class="bdl bdr tc"><a nc_type="edit" shippingid="' + shippingid + '" orderid="<?php echo $output["order_info"]["order_id"];?>" href="javascript:void(0);" class="ncbtn ncbtn-bluejeansjeans" >编辑</a></td>\n'+
' </tr>';
//获取tr所在的行号
var _index = $('a[shippingid=' + shippingid + ']').closest('tr').index();
//删除tr
$("tbody[nc_type=expresslist] tr:eq("+ _index + ")").remove();
$('tbody[nc_type=expresslist]').append(_html);
}
(。・v・。)
喜欢这篇文章吗?欢迎分享到你的微博、QQ群,并关注我们的微博,谢谢支持。