[英]how can i add thead and tbody tags in an existing tab with javascript
Hi my tab is generate by an app and i can't add in the html code the thead and tbody tags.嗨,我的选项卡是由应用程序生成的,我无法在 html 代码中添加 thead 和 tbody 标签。 So i would like add with javascript the tags actually my code is : ...
所以我想用javascript添加标签实际上我的代码是:...
<table id="__bookmark_1">
<tr>
<th>name</th>
<th>adress</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
... and i would like ... ......我想要......
<table id="__bookmark_1">
<thead>
<tr>
<th>name</th>
<th>adress</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tbody>
</table>
... ...
Thanks谢谢
hi in fact it to use datatables code i have founfd the way to嗨实际上它使用数据表代码我已经找到了方法
var myTable = jQuery("#__bookmark_1");
var thead = myTable.find("thead");
var thRows = myTable.find("tr:has(th)");
if (thead.length===0){ //if there is no thead element, add one.
thead = jQuery("<thead></thead>").appendTo(myTable);
}
var copy = thRows.clone(true).appendTo("thead");
thRows.remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.