Skip to content

Commit ee23133

Browse files
authored
Searching: getElement*, querySelector* (#246)
1 parent 63deea2 commit ee23133

File tree

3 files changed

+135
-135
lines changed

3 files changed

+135
-135
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
There are many ways to do it.
1+
Є багато способів зробити це.
22

3-
Here are some of them:
3+
Ось деякі з них:
44

55
```js
6-
// 1. The table with `id="age-table"`.
6+
// 1. Таблиця з `id="age-table"`.
77
let table = document.getElementById('age-table')
88

9-
// 2. All label elements inside that table
9+
// 2. Всі елементи label всередині цієї таблиці
1010
table.getElementsByTagName('label')
11-
// or
11+
// або
1212
document.querySelectorAll('#age-table label')
1313

14-
// 3. The first td in that table (with the word "Age")
14+
// 3. Перший td в цій таблиці (зі словом "Age")
1515
table.rows[0].cells[0]
16-
// or
16+
// або
1717
table.getElementsByTagName('td')[0]
18-
// or
18+
// або
1919
table.querySelector('td')
2020

21-
// 4. The form with the name "search"
22-
// assuming there's only one element with name="search" in the document
21+
// 4. форма з іменем "search"
22+
// припускаємо, що в документі є лише один елемент з name="search".
2323
let form = document.getElementsByName('search')[0]
24-
// or, form specifically
24+
// або безпосередньо форма
2525
document.querySelector('form[name="search"]')
2626

27-
// 5. The first input in that form.
27+
// 5. Перший input у цій формі.
2828
form.getElementsByTagName('input')[0]
29-
// or
29+
// або
3030
form.querySelector('input')
3131

32-
// 6. The last input in that form
33-
let inputs = form.querySelectorAll('input') // find all inputs
34-
inputs[inputs.length-1] // take the last one
32+
// 6. Останній input у цій формі
33+
let inputs = form.querySelectorAll('input') // знайти всі input
34+
inputs[inputs.length-1] // взяти останній
3535
```

2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 4
22

33
---
44

5-
# Search for elements
5+
# Пошук елементів
66

7-
Here's the document with the table and form.
7+
Ось документ із таблицею та формою.
88

9-
How to find?...
9+
Як знайти?...
1010

11-
1. The table with `id="age-table"`.
12-
2. All `label` elements inside that table (there should be 3 of them).
13-
3. The first `td` in that table (with the word "Age").
14-
4. The `form` with `name="search"`.
15-
5. The first `input` in that form.
16-
6. The last `input` in that form.
11+
1. Таблиця з `id="age-table"`.
12+
2. Усі елементи `label` всередині цієї таблиці (їх має бути 3).
13+
3. Перший `td` у цій таблиці (зі словом "Age").
14+
4. `form` з `name="search"`.
15+
5. Перший `input` у цій формі.
16+
6. Останній `input` у цій формі.
1717

18-
Open the page [table.html](table.html) in a separate window and make use of browser tools for that.
18+
Відкрийте сторінку [table.html](table.html) в окремому вікні та скористайтеся для цього інструментами браузера.

0 commit comments

Comments
 (0)