簡體   English   中英

在運行時將col添加到html表的colgroup

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

我用以下代碼段定義了表。

<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>

在這種情況下,我已經使用以下代碼片段將col附加到表的colgroup中。

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

但是它將在第0個索引中添加該列。 如何將col轉到colgroup表的最后一個

你的意思是append()

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM