Home >Web Front-end >Front-end Q&A >What does rows mean in javascript
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".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
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:
After clicking the button:
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!