Insert th in thead

后端 未结 4 1893
时光取名叫无心
时光取名叫无心 2021-02-01 16:15

I want to insert a th tag inside tr of thead element of a table. I am using insertCell method of row object created under

4条回答
  •  时光取名叫无心
    2021-02-01 16:44

    You can do it with vanilla JavaScript. Try this:

    HTML

    First

    JavaScript

    var tr = document.getElementById('table').tHead.children[0],
        th = document.createElement('th');
    th.innerHTML = "Second";
    tr.appendChild(th);
    

    Here is an example http://codepen.io/anon/pen/Bgwuf

提交回复
热议问题