木子屋 Dnawo's BLOG

利用insertRow和insertCell动态增加表格行和列.txt

👤 dnawo 📅 2007-03-03 👁 8528 👍 0 💬 0 🔄 本站原创
废话不说,看例子就可以了:
HTML
<script type="text/javascript">
var i = 1;
function insRow()
{
var j = 1;
var obj=document.getElementById('myTable').insertRow();
obj.insertCell().innerHTML = "<font color=red>第"+i+"行第1列</font>";
obj.insertCell().innerHTML = "<font color=red>第"+i+"行第2列</font>";
obj.insertCell().innerHTML = "<font color=red>第"+i+"行第3列</font>";
i++;
}
</script>
</head><body>
<table id="myTable" border="1">
</table>
<form>
<input type="button" onclick="insRow();" value="新增一行">
</form>

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 脚本全局变量的存活期 下一篇 → 53 CSS-Techniques You Couldn’t L…