querySelector

Browser functions that find elements in the page, by a CSS selector (querySelector) or by id (getElementById).

In more detail

querySelectorAll returns every match instead of the first. Searching the page couples code to its structure, so frameworks usually provide other ways to reach elements.

Example

Course examples use them to find the root element and check rendered output; in React components you normally use refs instead.

Related terms

Taught in

References