tags:

views:

213

answers:

0

I'm trying to insert a TH as the first column. But so far always put it at the end of all columns. Any help will be appreciate it. Thanks

var someNode  = document.createElement("th");
someNode.innerHTML = "Hello";
var sp = document.getElementById("table").getElementsByTagName("thead")[0].getElementsByTagName("tr")[0];
var ref = document.getElementById("table").getElementsByTagName("thead")[0].getElementsByTagName("tr")[0].getElementsByTagName("th")[0];
sp.insertBefore(someNode,ref);