我已使用以下代码段定义了表。
<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表的最后一个
答案 0 :(得分:1)
你的意思是append()
$('.gridheadercontainer table colgroup').append(doc.createElement('col'));