DOM Traversal
Once you've selected an Element, you can traverse to other elements in the tree using the following properties:
children
firstElementChild
lastElementChild
parentElement
nextElementSibling
previousElementSibling
.children
is an HTMLCollection
which is an array-like object. You can access its elements with bracket syntax []
and loop over it with for
loops.
Last updated
Was this helpful?