Short video - querySelector et querySelectorAll en Javascript

5 Jan 2023 · 2 min
2:27

In this concise French tutorial, the presenter introduces the JavaScript Selectors API, which lets developers access DOM elements using CSS‑style selectors. After briefly recalling traditional ways of targeting elements (hierarchical access, document.getElementById, document.getElementsByTagName, event‑based access), he demonstrates a simple HTML page containing two styled <div> elements (orange and yellow). He first shows the classic getElementById approach with an onclick handler that logs the element’s text via `this.textContent`. He then switches to the Selectors API, using `document.querySelector` with a CSS selector (by tag name or by ID) to retrieve the same element, explaining that `querySelector` returns only the first matching element. By logging `.textContent` he confirms the same result. The demo illustrates how to replace `this` with an explicit selector, and hints at the broader capability of `querySelectorAll` to return all matching elements, though the focus remains on the single‑element selector. The tutorial emphasizes the simplicity and CSS‑familiar syntax of the Selectors API for DOM manipulation.

Chapters

More from Yamossoun

8:56
youtube.com

Compteur synchrone - Logique séquentielle

2w ago
11:58
youtube.com

Compteur asynchrone et diviseur de fréquence - Logique séquentielle

3w ago
11:37
youtube.com

Les registres (parallèle et à décalage) - Logique séquentielle

1mo ago
6:14
youtube.com

Bascule T (Toggle) - Logique séquentielle

1mo ago
12:05
youtube.com

Bascule JK - Logique séquentielle

1mo ago
9:17
youtube.com

Bascule D flip-flop active sur front montant - Logique séquentielle

1mo ago
10:08
youtube.com

Bascule D Latch - Logique séquentielle

1mo ago
8:13
youtube.com

Bascule RS - Logique séquentielle

1mo ago
5:04
youtube.com

Logique séquentielle - Introduction

2mo ago
1:15
youtube.com

Le codeur - Logique combinatoire #codeur #logique #circuit #booleanlogic

2mo ago
1:56
youtube.com

Algorithme de calcule de la racine carrée par dichotomie #dichotomy #squareroot #algorithm

3mo ago
See all content