Ways of Accessing the DOM
querySelector and querySelectorAll
- Both take "CSS style" selectors.
- querySelector returns only the first match
- querySelectorAll returns 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!