|
1 |
| -There are many ways to do it. |
| 1 | +Є багато способів зробити це. |
2 | 2 |
|
3 |
| -Here are some of them: |
| 3 | +Ось деякі з них: |
4 | 4 |
|
5 | 5 | ```js
|
6 |
| -// 1. The table with `id="age-table"`. |
| 6 | +// 1. Таблиця з `id="age-table"`. |
7 | 7 | let table = document.getElementById('age-table')
|
8 | 8 |
|
9 |
| -// 2. All label elements inside that table |
| 9 | +// 2. Всі елементи label всередині цієї таблиці |
10 | 10 | table.getElementsByTagName('label')
|
11 |
| -// or |
| 11 | +// або |
12 | 12 | document.querySelectorAll('#age-table label')
|
13 | 13 |
|
14 |
| -// 3. The first td in that table (with the word "Age") |
| 14 | +// 3. Перший td в цій таблиці (зі словом "Age") |
15 | 15 | table.rows[0].cells[0]
|
16 |
| -// or |
| 16 | +// або |
17 | 17 | table.getElementsByTagName('td')[0]
|
18 |
| -// or |
| 18 | +// або |
19 | 19 | table.querySelector('td')
|
20 | 20 |
|
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". |
23 | 23 | let form = document.getElementsByName('search')[0]
|
24 |
| -// or, form specifically |
| 24 | +// або безпосередньо форма |
25 | 25 | document.querySelector('form[name="search"]')
|
26 | 26 |
|
27 |
| -// 5. The first input in that form. |
| 27 | +// 5. Перший input у цій формі. |
28 | 28 | form.getElementsByTagName('input')[0]
|
29 |
| -// or |
| 29 | +// або |
30 | 30 | form.querySelector('input')
|
31 | 31 |
|
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] // взяти останній |
35 | 35 | ```
|
0 commit comments