Skip to content

Commit 783a2e1

Browse files
authored
Update translation of 2-ui/1-document/04-searching-elements-dom (javascript-tutorial#668)
Update translation of 2-ui/1-document/04-searching-elements-dom (javascript-tutorial#668)
1 parent 9c57c73 commit 783a2e1

3 files changed

Lines changed: 188 additions & 193 deletions

File tree

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
实现的方式有很多种。
22

3-
以下是列举的一些方法
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"
21+
// 4. 带有 name="search" 的 form。
22+
// 假设文档中只有一个 name="search" 的元素
2323
let form = document.getElementsByName('search')[0]
24-
// or, form specifically
24+
// 或者,专门对于 form
2525
document.querySelector('form[name="search"]')
2626

27-
// 5. The first input in that form.
28-
form.getElementsByTagName('input')
29-
// or
27+
// 5. 表单中的第一个 input
28+
form.getElementsByTagName('input')[0]
29+
//
3030
form.querySelector('input')
3131

32-
// 6. The last input in that form.
33-
// there's no direct query for that
34-
let inputs = form.querySelectorAll('input') // search all
35-
inputs[inputs.length-1] // take last
32+
// 6. 表单中的最后一个 input
33+
let inputs = form.querySelectorAll('input') // 查找所有 input
34+
inputs[inputs.length-1] // 取出最后一个
3635
```

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ importance: 4
44

55
# 搜索元素
66

7-
这是带有表格和表单的文档
7+
这是带有表格(table)和表单(form)的文档
88

9-
如何查找?
9+
如何查找?……
1010

11-
1. `id="age-table"` 的表格。
12-
2. 所有的 `label` 元素都内嵌于表格(应该有三个)。
13-
3. 表格中的第一个 `td`字段是 "Age")。
14-
4. `form` 的一个字段是 `search`
15-
5. 第一个 `input` 在表单中
16-
6. 最后一个 `input` 在表单中
11+
1. 带有 `id="age-table"` 的表格。
12+
2. 表格内的所有 `label` 元素(应该有三个)。
13+
3. 表格中的第一个 `td`带有 "Age" 字段)。
14+
4. 带有 `name="search"``form`
15+
5. 表单中的第一个 `input`
16+
6. 表单中的最后一个 `input`
1717

18-
新开一个独立的窗口,打开页面 [table.html](table.html),然后再此页面上使用开发者工具
18+
在一个单独的窗口中打开 [table.html](table.html) 页面,并对此页面使用浏览器开发者工具

0 commit comments

Comments
 (0)