Ways of Accessing the DOM
querySelector and querySelectorAll
- Both use CSS selector syntax.
querySelectorreturns only the first matchquerySelectorAllreturns a list of items (even if it is a list of zero or one -- it returns a list!).
getElementById
This returns a single element node that we can directly operate on.
Remember that id values must be unique, so we only get a
single match!