【发布时间】:2019-01-14 06:19:57
【问题描述】:
我有一张这样的桌子:
<div class="table-wrapper">
<table id="HK_myTable">
<tr>
<th style="width:0.5%"></th>
<th style="width:2%">STORE</th>
<th style="width:10%">SECTION</th>
<th style="width:30%">ELEMENT</th>
<th style="width:48.5%">ACTION</th>
</tr>
<tr>
<td><a class="icon fa fa-trash" onclick="is_done($(this))"></a></td>
<td>2227</td>
<td>BATHROOM</td>
<td>CABIN GLAS</td>
<td>NEED REPARATION</td>
</tr>
<tr>
</table>
</div>
当我点击每一行的第一个单元格时,我希望在点击的单元格下方创建一个新行。这是我的 JS 代码:
function is_done(row)
{
var currentdate = new Date();
var tm = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes();
row.closest('td').html('Maintenance'); //This works
row.closest('tr').append('<tr><td>checked on'+tm+'<td></tr>'); //Here is the problem.. no row is added under the clicked <td>
}
【问题讨论】:
标签: jquery html-table append closest