Home  >  Article  >  Web Front-end  >  What does rows mean in javascript

What does rows mean in javascript

WBOY
WBOYOriginal
2022-03-10 15:38:374425browse

In JavaScript, rows means "rows". The rows collection returns an array of all rows in the table and can return the number of tr elements in the collection. The collection includes all the elements defined in thead, tfoot and tbody. rows, the syntax is "tableObject.rows".

What does rows mean in javascript

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

What does rows mean in javascript

The rows collection returns an array of all rows (TableRow objects) in the table, that is, an HTMLCollection.

This set includes all lines defined in ,

and .

Syntax

tableObject.rows[]

The example is as follows:

<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>

Output result:

What does rows mean in javascript

After clicking the button:

What does rows mean in javascript

Related recommendations: javascript learning tutorial

The above is the detailed content of What does rows mean in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn