Javascript 在运行时将col添加到html表的colgroup中
我已经用下面的代码片段定义了这个表Javascript 在运行时将col添加到html表的colgroup中,javascript,jquery,html,Javascript,Jquery,Html,我已经用下面的代码片段定义了这个表 <div class="gridheadercontainer"> <table class="table" cellspacing="0"> <colgroup> <col style="width: 150px;"> <col style="width: 150px;">
<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>
但它将在第0个索引中添加该列。
如何将列添加到colgroup表的最后一个您的意思是
谢谢您的回复,我已经尝试了提供的代码。但我仍然面临着同样的问题,它没有添加到colgroup@Raja你能分享你的脚本吗?谢谢你,用简单的html。它工作得很好。我将检查我的实现。非常感谢。
$('.gridheadercontainer table colgroup').prepend(doc.createElement('col'));
$('.gridheadercontainer table colgroup').append(doc.createElement('col'));