Update getAncestors.md

This commit is contained in:
Angelos Chalaris
2021-01-05 22:45:34 +02:00
committed by GitHub
parent 55eb541f5c
commit c0860b96ea

View File

@ -5,7 +5,7 @@ tags: browser,beginner
Returns all the ancestors of an element from the document root to the given element.
- Use a `Node.parentNode` and a `while` loop to move up the ancestor tree of the element.
- Use `Node.parentNode` and a `while` loop to move up the ancestor tree of the element.
- Use `Array.prototype.unshift()` to add each new ancestor to the start of the array.
```js