Selecting elements

Element selection retrieves DOM nodes in order to manipulate them. document.querySelector returns the first element matching a CSS selector, and querySelectorAll all those that match, as a static list. getElementById targets an identifier. A selection with no result returns null.

Example

const bouton = document.querySelector('.envoyer')

Related concepts

The whole glossary