我有这样的表结构.相当简单.
<table id="myTable" class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
在运行时,我将一个新行绑定到此表以获取特定内容rowclick.这个新行包含一个新表.
现在再次单击该行,我希望能够删除新添加的行row(the new table).
我在用bootstrap table.
这是我到目前为止所尝试的.
$('#myTable').on('click-row.bs.table', function (e, row, $element) {
//if ($element.has('#newlyAddedTable').length) { ....// did not work
if ($('#myTable').has('#newlyAddedTable').length) { // this removes the table on any row click. Not what I intend to do
{
$("#newlyAddedTable").remove();
} else {
// some …Run Code Online (Sandbox Code Playgroud)