|
1 | | -There are many ways to do it. |
| 1 | +Ada banyak cara untuk melakukan ini. |
2 | 2 |
|
3 | | -Here are some of them: |
| 3 | +Ini adalah salah satu caranya: |
4 | 4 |
|
5 | 5 | ```js |
6 | | -// 1. The table with `id="age-table"`. |
| 6 | +// 1. The table with `id="age-table"` (1. tabel dengan `id="age-table"`). |
7 | 7 | let table = document.getElementById('age-table') |
8 | 8 |
|
9 | | -// 2. All label elements inside that table |
| 9 | +// 2. All label elements inside that table (2. Semua elemen label di dalam tabel). |
10 | 10 | table.getElementsByTagName('label') |
11 | | -// or |
| 11 | +// or |
12 | 12 | document.querySelectorAll('#age-table label') |
13 | 13 |
|
14 | | -// 3. The first td in that table (with the word "Age") |
| 14 | +// 3. The first td in that table (with the word "Age") (3. elemen td pertama pada tabel (dengan kata "Age")). |
15 | 15 | table.rows[0].cells[0] |
16 | 16 | // or |
17 | 17 | table.getElementsByTagName('td')[0] |
18 | 18 | // or |
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. The form with the name "search" (Formulir dengan nama "search"). |
| 22 | +// assuming there's only one element with name="search" in the document (mengasumsikan hanya ada satu elemen dengan nama="search" di dalam dokumen). |
23 | 23 | let form = document.getElementsByName('search')[0] |
24 | | -// or, form specifically |
| 24 | +// or, form specifically (atau, khususnya formulir). |
25 | 25 | document.querySelector('form[name="search"]') |
26 | 26 |
|
27 | | -// 5. The first input in that form. |
| 27 | +// 5. The first input in that form (elemen input pertama pada formulir). |
28 | 28 | form.getElementsByTagName('input')[0] |
29 | 29 | // or |
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. The last input in that form (elemen input terakhir pada formulir). |
| 33 | +let inputs = form.querySelectorAll('input') // find all inputs (mencari semua elemen input). |
| 34 | +inputs[inputs.length-1] // take the last one (mengambil elemen input terakhir). |
35 | 35 | ``` |
0 commit comments