2014年7月4日 星期五

[Javascript] Add row into Table




Javascript


var table_list;

function addRow()
{
a
= table_list.insertRow(1);
a
.insertCell(0).innerHTML="happy";
a
.insertCell(1).innerHTML="happy";
a
.insertCell(2).innerHTML="happy";
a
.insertCell(3).innerHTML="happy";


}

function init()
{
table_list
= document.getElementById("table");
}


HTML


<table id="table">
<thead>
<tr>
<th>Address</th>
<th>Protocol</th>
<th>Start</th>
<th>End</th>
</tr>
</thead>
<tbody>
</tbody>
</table>


Reference:


TableRow insertCell() Method

Related Posts:

0 意見:

張貼留言