简体   繁体   English

在运行时将col添加到html表的colgroup

[英]Add col to the colgroup of html table in run time

I have define the table with the following code snippet. 我用以下代码段定义了表。

<div class="gridheadercontainer">
        <table class="table" cellspacing="0">
            <colgroup>
                <col style="width: 150px;">
                <col style="width: 150px;">
                <col style="width: 150px;">
                <col style="width: 150px;">
                <col style="width: 150px;">
            </colgroup>
           <thead>
           <tr class="columnheader" style="cursor: pointer;">
               <th class="headercell"><div class="headercelldiv">Task name</div></th>
               <th class="headercell"><div class="headercelldiv">Start time</div></th>
               <th class="headercell"><div class="headercelldiv">End time</div></th>
               <th class="headercell"><div class="headercelldiv">Duration</div></th>
               <th class="headercell"><div class="headercelldiv">Status</div></th>
               <th class="headercell"><div class="headercelldiv"></div></th>
           </tr>
          </thead>
            <tbody class="hide"><tr><td></td><td></td><td></td><td></td><td></td></tr></tbody>
        </table>
    </div>

In this case I have use the following code snippet to append the col to the colgroup of table. 在这种情况下,我已经使用以下代码片段将col附加到表的colgroup中。

$('.gridheadercontainer table colgroup').prepend(doc.createElement('col'));

But it will add the column in the 0th index. 但是它将在第0个索引中添加该列。 How to the col to the last of the colgroup table 如何将col转到colgroup表的最后一个

你的意思是append()

$('.gridheadercontainer table colgroup').append(doc.createElement('col'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM