首页  >  文章  >  web前端  >  javascript中rows是什么意思

javascript中rows是什么意思

WBOY
WBOY原创
2022-03-10 15:38:374298浏览

在JavaScript中,rows是“行”的意思,rows集合返回表格中所有行的一个数组,能够返回集合中tr元素的数目,该集合包括thead、tfoot和tbody中定义的所有行,语法为“tableObject.rows”。

javascript中rows是什么意思

本教程操作环境:windows10系统、javascript1.8.5版、Dell G3电脑。

javascript中rows是什么意思

rows 集合返回表格中所有行(TableRow 对象)的一个数组,即一个 HTMLCollection。

该集合包括 ae20bdd317918ca68efdc799512a9b39、06669983c3badb677f993a8c29d18845 和 92cee25da80fac49f6fb6eec5fd2c22a 中定义的所有行。

语法

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>

输出结果:

06.png

点击按钮后:

07.png

相关推荐:javascript学习教程

以上是javascript中rows是什么意思的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn