javascript中rows是什么意思

javascript中rows是什么意思,第1张

javascript中rows是什么意思

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

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

javascript中rows是什么意思

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

该集合包括 <thead>、<tfoot> 和 <tbody> 中定义的所有行。

语法

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>

输出结果:

点击按钮后:

相关推荐:javascript学习教程

以上就是javascript中rows是什么意思的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/699032.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-22
下一篇 2022-04-22

发表评论

登录后才能评论

评论列表(0条)

保存