# querySelector()

*noun*

say it: **“KWEER-ee suh-LEK-ter”** **/ˈkwɪəri səˈlɛktər/**

A DOM method that returns the first element matching a CSS selector.

## What does **querySelector()** do in JavaScript?

**querySelector()** — A DOM method that returns the first element matching a CSS selector.

```javascript
const button = document.querySelector("#checkout");
```

## In a sentence

- “**querySelector**("#cart .total") found the cart's total.”

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/queryselector
