Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Using querySelector and querySelectorAll | Understanding and Selecting Elements
DOM Manipulation with JavaScript

bookUsing querySelector and querySelectorAll

Modern JavaScript provides powerful methods for selecting elements from the DOM using CSS selectors. The querySelector method allows you to select the first element that matches a given CSS selector, while querySelectorAll returns a static NodeList of all elements matching the selector. CSS selector syntax lets you target elements by tag, class, ID, attribute, or even hierarchical relationships. For example, "div", .item, and #header select elements by tag, class, and ID, respectively. You can also use more complex selectors like "ul li.active" to find all li elements with the class active inside a ul. These methods give you flexibility and precision when working with the DOM.

index.html

index.html

style.css

style.css

copy
question mark

Which selector would you use with querySelectorAll to select all <li> elements with the class "item" inside a <ul> with the class "menu"?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you give more examples of CSS selectors I can use with querySelector?

How do I use querySelector and querySelectorAll in JavaScript code?

What is the difference between querySelector and getElementById?

Awesome!

Completion rate improved to 6.67

bookUsing querySelector and querySelectorAll

Свайпніть щоб показати меню

Modern JavaScript provides powerful methods for selecting elements from the DOM using CSS selectors. The querySelector method allows you to select the first element that matches a given CSS selector, while querySelectorAll returns a static NodeList of all elements matching the selector. CSS selector syntax lets you target elements by tag, class, ID, attribute, or even hierarchical relationships. For example, "div", .item, and #header select elements by tag, class, and ID, respectively. You can also use more complex selectors like "ul li.active" to find all li elements with the class active inside a ul. These methods give you flexibility and precision when working with the DOM.

index.html

index.html

style.css

style.css

copy
question mark

Which selector would you use with querySelectorAll to select all <li> elements with the class "item" inside a <ul> with the class "menu"?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
some-alt