Node

Node Hierarchy


DOM Tree


Processing

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <h1>Lorem ispum</h1>
  <p>Ipsum dolor lorem</p>
</body>
</html>

Output:

Node.childNodes


const tbody = document.querySelector('table tbody')
const rows = tbody.childNodes

for (var i = 0; i < rows.length; i++) {
  rows[i]
}

Node.firstChild


const tbody = document.querySelector('table tbody')
tbody.firstChild

Node.lastChild


const tbody = document.querySelector('table tbody')
tbody.lastChild

Node.parentNode


const tbody = document.querySelector('table tbody')
tbody.parentNode