I have to create a thead using the first row from a tbody. I don't have full control of the markup so I'm using jQuery to do this.
I have been successful using some borrowed script but when I add more than one table to a page the first row seems to be being duplicated across the following tables
I would imagine that I need to target the parent table, normally I would give each table an ID but I cannot as these are generated for me.
an example of what's happening can be seen on this fiddle http://jsfiddle.net/FGH6B/
My current jquery is as follows
jQuery("document").ready( function() {
var mytable = $("table");
mytable.prepend(document.createElement('thead'));
$("table thead").append($("tbody tr:eq(0)"));
});