Ale*_*Man 1 html javascript html-table
我创建了一个应用程序,用于在 javascript 中获取 html 形式的表格内容,该应用程序工作正常,但问题是在 javascript 中获取 html 内容后,我想从 javascript html 表格内容中删除第一列
谁能告诉我一些解决方案
function printData() {
var divToPrint = document.getElementById("printTable");
alert(divToPrint.outerHTML);
}
$('button').on('click', function () {
printData();
})
Run Code Online (Sandbox Code Playgroud)
您可以克隆该元素,删除第一个子td元素和第一个th,然后读取outerHTML克隆元素的:
$(divToPrint).clone()
.find('th:first-child, td:first-child').remove().end()
.prop('outerHTML');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2944 次 |
| 最近记录: |