在表的最后一行之前获取整行

问题描述 投票:0回答:1

我有一个表,该表首先从数据库加载数据。该表具有添加行功能,该功能位于最后一个tr中。我希望能够克隆上一行。我该怎么做?

$ row = $(this).closest('tr')。prev('tr'),但这不起作用。

var
                $table = $(this).closest('table'),
                $row = $(this).closest('tr').prev('tr'),
                $newRow = $row.clone();
                $table.append($('table.order-list').append($newRow));
jquery html
1个回答
0
投票

找到了,是

var
                len = $('#tblId tr').length,
                $row = $('#tblId tr').eq(len - 2),
© www.soinside.com 2019 - 2024. All rights reserved.