使用本文中的javascript示例
stack overflow post
您可以使用一个按钮自动选择一个表。然后可以将所选表复制到剪贴板。
我的用户将把此数据复制到Excel模板中,不需要标题信息(
<th></th>
或
<thead></thead>
)
我的桌子看起来像这样:
<table class="sortable">
<thead>
<tr><th>Person</th><th>Monthly pay</th></tr>
</thead>
<tbody>
<tr><td>Bob</td><td>£12,000</td></tr>
<tr><td>Doug</td><td>£8,500</td></tr>
<tr><td>Sam</td><td>£9,200</td></tr>
<tr><td>Nick</td><td>£15,300</td></tr>
</tbody>
<tfoot>
<tr><td>TOTAL</td><td>£45,000</td></tr>
</tfoot>
</table>
如何取消选择标题信息?
乳房1
关键是选择tbody(假设不需要tfoot)。
<input type="image" src="table.png" name="image" onclick="selectElementContents( document.getElementById('theebody') );">