将表的特定单元格复制到另一页

Copy specific cells of a table to another page

本文关键字:复制 一页 单元格      更新时间:2023-09-26

我打算将表的特定单元格复制到另一个页面,我已经尝试过复制。但是,我只能复制整个表格,而不能复制特定的单元格。我有下面的示例代码。

例如,我有

Product ID | Product Name | Qty | Price
-----------------------------------------------------
     1     |   Adidas     | 1   |  $50  |  Delete Btn

我希望将此内容复制到我的checkoutList上,但不包括作为最后一个单元格的Delete btn。我可以知道怎么做吗?

<table id="myList">
                <thead>
                    <tr>
                        <td>Product Name</td>
                        <td>Qty</td>
                        <td>Price</td>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

这是将用复制的内容填充的表

<table id="checkoutList">
            </table>

这是我的复制表功能。

function copyTable() {

      window.location.href = "#/app/checkOut";

      //copyTable
      var source = document.getElementById('myList');
      var destination = document.getElementById('checkoutList');
      var copy = source.cloneNode(true);
      copy.setAttribute('id', 'checkoutList');
      destination.parentNode.replaceChild(copy, destination);
    }

您正在查找.childs属性。