getElementById |
Single element |
When targeting a unique element. |
getElementsByClassName |
Live collection |
For multiple elements by class. |
getElementsByTagName |
Live collection |
For elements by tag name. |
querySelector |
Single element |
Flexible, for complex selectors. |
querySelectorAll |
Static NodeList |
When multiple matches are needed. |