【问题标题】:Moving table row from one table to the other using Jquery使用 Jquery 将表行从一个表移动到另一个表
【发布时间】:2009-03-31 18:57:04
【问题描述】:

我有以下 HTML

<table id="tbl1">
  <!-- Table row trHeader should be here based on a flag //-->  
</table>
<table id="tbl2">
  <tr id="trHeader">
     <td>test</td>
  </tr>
</table>

我有一个标志(本质上是一个按钮),我可以用它来移动 id="tbl2" 的表格行。我如何根据这个标志将它切换回相同的位置。

【问题讨论】:

    标签: jquery jquery-ui


    【解决方案1】:

    试试这样的

    $('#tbl1').append($('#trHeader').remove());
    

    更新,我不确定您的按钮在哪里进行切换,我将假设您在单击标题行时进行切换。如果不是,请告诉我。

    $('#trHeader').toggle(function() {
      $('#tbl1').append($(this).remove());
    }, function() {
      $('#tbl2').append($(this).remove());
    });
    

    【讨论】:

    • 我想在追加和删除之间切换。我该怎么做?
    • 如果我想从 Table1 中取出一行并将其插入 Table2 的另外两行之间怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2016-03-22
    • 2016-07-13
    • 1970-01-01
    • 2015-04-15
    • 1970-01-01
    相关资源
    最近更新 更多