Today, they are mostly history, as querySelector is more powerful and shorter to write.… querySelector
CSS-selector
✔
-
querySelectorAll
CSS-selector
✔
-
getElementById
id
-
-
getElementsByName… getElementsByTagName
tag or '*'
✔
✔
getElementsByClassName
class
✔
✔
By far the most used are querySelector
Encapsulation.Shadow DOM is strongly delimited from the main document:
Shadow DOM elements are not visible to querySelector… :
Have their own ids space,
Invisible to JavaScript selectors from the main document, such as querySelector
navigation like nextElementSibling, children and searching methods like getElementsByTagName, querySelector