DOM Properties
HTMLTableElement.rows
Read-only live collection. Provides table rows in table order, including rows in thead, tbody and tfoot. Insertions and deletions change the collection; take a snapshot before mutating while iterating if necessary. Example result: 2.
Formal Syntax & Structure
html syntaxhtml
element.rowsReturn Value
HTMLCollection
Property value. Read-only live collection.
Working Example
Example Snippethtml
<table id="demo"> <tbody> <tr> <td>1</td> </tr> </tbody></table><p> Result: <output id="result"></output></p><script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; e.insertRow(-1).insertCell().textContent='2'; result(e.rows.length);</script>