Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript将第一行放在AD中_Javascript_Html_Css - Fatal编程技术网

Javascript将第一行放在AD中

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

是否可以使用javascript将第一行移动到标记中,如下所示

变成

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