`

JS操作表

    博客分类:
  • JS
 
阅读更多
<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" onclick="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>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics