Javascript将第一行放在AD中
是否可以使用javascript将第一行移动到标记中,如下所示 变成Javascript将第一行放在AD中,javascript,html,css,Javascript,Html,Css,是否可以使用javascript将第一行移动到标记中,如下所示 变成 <table id="TBL1399802283490" class="confluenceTable"> <thead> <tr> <th class="confluenceTh" style="cursor: pointer;">Server Name </th> <th class="confluenceTh" t
<table id="TBL1399802283490" class="confluenceTable">
<thead>
<tr>
<th class="confluenceTh" style="cursor: pointer;">Server Name </th>
<th class="confluenceTh" title="null" style="cursor: pointer;">Network Zone </th>
<th class="confluenceTh" title="null" style="cursor: pointer;">Operational Status </th>
</tr>
</thead>
<tbody>
<tr>
<td class="confluenceTd"><div style="left:1em;right:1em"> w264521f </div> </td>
<td class="confluenceTd"><div style="left:1em;right:1em"> GREEN </div> </td>
<td class="confluenceTd"><div style="left:1em;right:1em"> READY </div> </td>
</tr>
</tbody>
</table>
我不太熟悉Javascript,所以非常感谢您的帮助 这应该适用于代码中给出的表,对于一般表,最好以更安全的方式获取元素
var table = document.getElementById('TBL1399802283490');
var thead = document.createElement('THEAD');
var tbody = table.getElementsByTagName('TBODY')[0];
var tr = table.getElementsByTagName('TR')[0];
table.appendChild(thead);
tbody.removeChild(tr);
thead.appendChild(tr);
如何生成表?使用克隆将内容从一个地方复制到另一个地方。
var table = document.getElementById('TBL1399802283490');
var thead = document.createElement('THEAD');
var tbody = table.getElementsByTagName('TBODY')[0];
var tr = table.getElementsByTagName('TR')[0];
table.appendChild(thead);
tbody.removeChild(tr);
thead.appendChild(tr);