Clone table header and set as the first element, and replace header's th with td

Clone table header and replace header's th with td

var tableHeaderRow = '#tableId tbody tr:nth-child(1)'; // this is th.
var copy = $(tableHeaderRow).clone();
$('#tableViewHeader').prepend(copy); // add this row as the first element in parent container.

$('#tableViewHeader').find('th').wrapInner('<td />').contents().unwrap();
$('#tableViewHeader').find('tbody').contents().unwrap();
原文地址:https://www.cnblogs.com/webglcn/p/4701736.html