DOM Interfaces

HTMLTableRowElement

Represents a row in a table and exposes its cells and row indices. rowIndex is relative to the table; sectionRowIndex is relative to the containing section. These indices can change as rows move. Example result: 1.

Formal Syntax & Structure

html syntaxhtml
const element = document.getElementById('demo'); // HTMLTableRowElement

Return Value

HTMLTableRowElement

An existing HTML DOM object associated with the tr element in this example; this interface is a type, not a function return contract.

Working Example

Example Snippethtml
<table>  <tbody>    <tr id="demo">      <td>5</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); };  result(e.cells.length);</script>
HTML Reference