限制添加行功能不起作用,请帮助
这是一个简单的带有函数的 javascript 添加行,然后我不知道如何限制附加行,例如最大行数。 5 行,任何想法和指针或示例,我将不胜感激
<script type="text/javascript">
function addRow() {
var newRow = document.all("tblGrid").insertRow();
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t1'><input type='button' value='Delete' onclick='removeRow(this);'/>";
//if(oCell>=5)return;
}
</script>
提前致谢
This is a simple javascript add row with functions, then I don't know how to limit the additional row e.g. for max. 5 rows, any idea and pointer or example(s) I would be appreciated
<script type="text/javascript">
function addRow() {
var newRow = document.all("tblGrid").insertRow();
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t1'><input type='button' value='Delete' onclick='removeRow(this);'/>";
//if(oCell>=5)return;
}
</script>
Thanks In advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加之前计算行数。行只是表元素中的一个数组 - 您可以通过
length
获取其长度Count rows before adding. Rows are just an array within the table element - you can get its length via
length