<table id="myTable" >
<tr>
<td>檔案名稱</td>
<td>檔案大小</td>
<td>操作</td>
</tr>
</table>
<script type="text/javascript">
var num = document.getElementById("myTable").rows.length;
var Tr = document.getElementById("myTable").insertRow(num);
Tr.id = ‘rowid’ + num;
Td = Tr.insertCell(Tr.cells.length);
Td.setAttribute(‘align’,'left’);
Td.innerHTML = ‘檔案1’;
Td = Tr.insertCell(Tr.cells.length);
Td.innerHTML = ’10KB’;
Td = Tr.insertCell(Tr.cells.length);
Td.innerHTML = ‘<a href="javascript:void(0)" onclick="del_row(\’rowid’ + num + ‘\’)">刪除</a>’;
function del_row(rowid){
var row = document.getElementById(rowid);
row.parentNode.removeChild(row);
}
</script>