<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table>
<tbody id="result">
<tr>
请点击Click Me
</tr>
</tbody>
</table>
<input type="button" value="Click Me" οnclick="executeJS();return false;"/>
<script type="text/javascript">
function executeJS() {
var tbody = document.getElementById('result');
for(var i=tbody.rows.length;i>0;i--){
tbody.deleteRow(i-1);
}
for(var i=0;i<5;i++){
var row = tbody.insertRow(i);
var cell = row.insertCell(0);
cell.innerHTML = '测试'+i;
cell = row.insertCell(1);
cell.innerHTML = i;
cell = row.insertCell(2);
cell.innerHTML = i*i;
}
}
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table>
<tbody id="result">
<tr>
请点击Click Me
</tr>
</tbody>
</table>
<input type="button" value="Click Me" οnclick="executeJS();return false;"/>
<script type="text/javascript">
function executeJS() {
var tbody = document.getElementById('result');
for(var i=tbody.rows.length;i>0;i--){
tbody.deleteRow(i-1);
}
for(var i=0;i<5;i++){
var row = tbody.insertRow(i);
var cell = row.insertCell(0);
cell.innerHTML = '测试'+i;
cell = row.insertCell(1);
cell.innerHTML = i;
cell = row.insertCell(2);
cell.innerHTML = i*i;
}
}
</script>
</body>
</html>