在javascript中接收到html内容后删除html表格第一列

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)

und*_*ned 5

您可以克隆该元素,删除第一个子td元素和第一个th,然后读取outerHTML克隆元素的:

$(divToPrint).clone()
             .find('th:first-child, td:first-child').remove().end()
             .prop('outerHTML');
Run Code Online (Sandbox Code Playgroud)