How do I add the problem is my table has 1 or 2 th rows?
What you need to do is remove the rows and append them to a thead element jsFiddle exmaple
and
this using jQuery?
$(\'#myTable tr
var myTable = jQuery("#myTable");
var thead = myTable.find("thead");
var thRows = myTable.find("tr:has(th)");
if (thead.length===0){ //if there is no thead element, add one.
thead = jQuery("").appendTo(myTable);
}
var copy = thRows.clone(true).appendTo("thead");
thRows.remove();