javascript中rows是什么意思
时间:2022-03-10 15:38
在JavaScript中,rows是“行”的意思,rows集合返回表格中所有行的一个数组,能够返回集合中tr元素的数目,该集合包括thead、tfoot和tbody中定义的所有行,语法为“tableObject.rows”。 本教程操作环境:windows10系统、javascript1.8.5版、Dell G3电脑。 rows 集合返回表格中所有行(TableRow 对象)的一个数组,即一个 HTMLCollection。 该集合包括 <thead>、<tfoot> 和 <tbody> 中定义的所有行。 语法 示例如下: 输出结果: 点击按钮后: 相关推荐:javascript学习教程 以上就是javascript中rows是什么意思的详细内容,更多请关注gxlsystem.com其它相关文章!javascript中rows是什么意思
tableObject.rows[]
<html>
<head>
<meta charset="utf-8">
<title>1234</title>
<script>
function displayResult(){
alert(document.getElementById("myTable").rows.length);
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">显示表的行数</button>
</body>
</html>