Assume I have 4 “th” elements on the page and on click of the button I need to create another “th” element but with specific position. For example if it’s 1997 it’ll be created in between 1995 and 2000 elements, and so on.
<table>
<tr>
<th>1990</th>
<th>1995</th>
<th>2000</th>
<th>2005</th>
</tr>
......
This is the code I have, but it creates new “th” at the very end.
var tblHeadObj = document.getElementById('<%=Me.GridView1.ClientID %>'); //table head
var newTH = tblHeadObj.rows[0].appendChild(document.createElement("th"))