OwenWu

<html>
<body>
<table id=tableList border=1 width=100>
    <tr><td>1</td></tr>
</table>
<button onclick=addRow()>插入行</button>
</body>

<script type="text/javascript">
var num = 1;
function addRow()
{
 num ++;
 InsertRow(tableList,"<tr><td>"+num+"新行</td></tr>");
}
function InsertRow(table,rowHtml)
{
    var o=document.createElement("div"),ol;
    o.innerHTML="<table>"+rowHtml+"</table>"
    ol=o.childNodes[0].tBodies[0].rows
    while(ol.length>0){
        table.tBodies[0].appendChild(ol[0])
    }
}
</script>

 

 

Table的 tBodies属性是一个JS中的集合,而不是数组,没有sort()方法,所以不能用来直接排序。

分类:

技术点:

相关文章:

  • 2021-04-05
  • 2021-08-12
  • 2022-01-27
  • 2021-06-28
  • 2021-05-20
  • 2021-09-16
  • 2021-09-02
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-07-07
  • 2022-12-23
  • 2021-09-30
  • 2021-12-17
相关资源
相似解决方案