diff --git a/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md b/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md index c73aecd99..7fdacc950 100644 --- a/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md +++ b/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md @@ -1,35 +1,35 @@ -There are many ways to do it. +Є багато способів зробити це. -Here are some of them: +Ось деякі з них: ```js -// 1. The table with `id="age-table"`. +// 1. Таблиця з `id="age-table"`. let table = document.getElementById('age-table') -// 2. All label elements inside that table +// 2. Всі елементи label всередині цієї таблиці table.getElementsByTagName('label') -// or +// або document.querySelectorAll('#age-table label') -// 3. The first td in that table (with the word "Age") +// 3. Перший td в цій таблиці (зі словом "Age") table.rows[0].cells[0] -// or +// або table.getElementsByTagName('td')[0] -// or +// або table.querySelector('td') -// 4. The form with the name "search" -// assuming there's only one element with name="search" in the document +// 4. форма з іменем "search" +// припускаємо, що в документі є лише один елемент з name="search". let form = document.getElementsByName('search')[0] -// or, form specifically +// або безпосередньо форма document.querySelector('form[name="search"]') -// 5. The first input in that form. +// 5. Перший input у цій формі. form.getElementsByTagName('input')[0] -// or +// або form.querySelector('input') -// 6. The last input in that form -let inputs = form.querySelectorAll('input') // find all inputs -inputs[inputs.length-1] // take the last one +// 6. Останній input у цій формі +let inputs = form.querySelectorAll('input') // знайти всі input +inputs[inputs.length-1] // взяти останній ``` diff --git a/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md b/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md index f0b54beac..9b88ecbc0 100644 --- a/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md +++ b/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md @@ -2,17 +2,17 @@ importance: 4 --- -# Search for elements +# Пошук елементів -Here's the document with the table and form. +Ось документ із таблицею та формою. -How to find?... +Як знайти?... -1. The table with `id="age-table"`. -2. All `label` elements inside that table (there should be 3 of them). -3. The first `td` in that table (with the word "Age"). -4. The `form` with `name="search"`. -5. The first `input` in that form. -6. The last `input` in that form. +1. Таблиця з `id="age-table"`. +2. Усі елементи `label` всередині цієї таблиці (їх має бути 3). +3. Перший `td` у цій таблиці (зі словом "Age"). +4. `form` з `name="search"`. +5. Перший `input` у цій формі. +6. Останній `input` у цій формі. -Open the page [table.html](table.html) in a separate window and make use of browser tools for that. +Відкрийте сторінку [table.html](table.html) в окремому вікні та скористайтеся для цього інструментами браузера. diff --git a/2-ui/1-document/04-searching-elements-dom/article.md b/2-ui/1-document/04-searching-elements-dom/article.md index 5af6435ce..133951bd3 100644 --- a/2-ui/1-document/04-searching-elements-dom/article.md +++ b/2-ui/1-document/04-searching-elements-dom/article.md @@ -1,93 +1,93 @@ -# Searching: getElement*, querySelector* +# Пошук: getElement*, querySelector* -DOM navigation properties are great when elements are close to each other. What if they are not? How to get an arbitrary element of the page? +Властивості навігації по DOM чудові, коли елементи розташовані близько один до одного. А якщо ні? Як отримати довільний елемент сторінки? -There are additional searching methods for that. +Для цього існують додаткові методи пошуку. -## document.getElementById or just id +## document.getElementById або просто id -If an element has the `id` attribute, we can get the element using the method `document.getElementById(id)`, no matter where it is. +Якщо елемент має атрибут `id`, ми можемо отримати його за допомогою методу `document.getElementById(id)`, незалежно від того, де він знаходиться. -For instance: +Наприклад: ```html run
Your age: | +Ваш вік: |
Method | -Searches by... | -Can call on an element? | -Live? | +Метод | +Шукає, використовуючи... | +Чи може викликатися на елементі? | +Чи повертає живу колекцію? |
querySelector |
-CSS-selector | +CSS-селектор | ✔ | - | |||
querySelectorAll |
-CSS-selector | +CSS-селектор | ✔ | - | |||
getElementsByName |
-name |
+ім’я |
- | ✔ | |||
getElementsByTagName |
-tag or '*' |
+тег або '*' |
✔ | ✔ | |||
getElementsByClassName |
-class | +клас | ✔ | ✔ |
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: