小编Nit*_*n P的帖子

从父表中查找子表选择器 - jQuery

我有这样的表结构.相当简单.

  <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)

javascript jquery twitter-bootstrap

7
推荐指数
1
解决办法
1898
查看次数

标签 统计

javascript ×1

jquery ×1

twitter-bootstrap ×1