首页 > 代码库 > 添加标签 | 标签内

添加标签 | 标签内

现在TD是HTMLTableCellElement,TD.outerHtml = <td class="current highlight">C2</td>

我要往td里添加一个div

<td class="current highlight">C2

  <div id="remmem">

      This is a newcon

  </div>

</td>

 

一:

var newNode = document.createElement("div");

newNode.id = "remmem";


newNode.innerHTML =" This is a newcon ";

newNode.style.color = "red";

二:

TD.appendChild(newNode);

效果:<td class="current highlight">C3<div id="remmem">This is a newcon </div></td>

 

添加标签 | 标签内