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();

 

posted @ 2015-08-04 13:23  webglcn  阅读(166)  评论(0编辑  收藏  举报