You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/1-document/03-dom-navigation/article.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,69 +63,69 @@ Portanto, no exemplo abaixo, o primeiro `alert` apresentará ` null`:
63
63
No DOM, o valor `null` significa "não existe" ou "nenhum nó".
64
64
```
65
65
66
-
## Children: childNodes, firstChild, lastChild
66
+
## Filhos: childNodes, firstChild, lastChild
67
67
68
-
There are two terms that we'll use from now on:
68
+
Existem dois termos que usaremos a partir de agora:
69
69
70
-
- **Child nodes (or children)** -- elements that are direct children. In other words, they are nested exactly in the given one. For instance, `<head>` and `<body>` are children of `<html>` element.
71
-
- **Descendants** -- all elements that are nested in the given one, including children, their children and so on.
70
+
- **Nós filhos** -- elementos que são filhos diretos. Em outras palavras, eles estão exatamente aninhados no elemento pai. Por exemplo, `<head>` e `<body>` são filhos do elemento `<html>`.
71
+
- **Descendentes** -- todos os elementos aninhados em um determinado elemento, incluindo filhos, netos, bisnetos e assim por diante.
72
72
73
-
For instance, here `<body>` has children `<div>` and `<ul>` (and few blank text nodes):
73
+
Por exemplo, aqui `<body>` tem `<div>` e `<ul>` como filhos (e alguns nós de texto em branco):
74
74
75
75
```html run
76
76
<html>
77
77
<body>
78
-
<div>Begin</div>
78
+
<div>Começo</div>
79
79
80
80
<ul>
81
81
<li>
82
-
<b>Information</b>
82
+
<b>Informação</b>
83
83
</li>
84
84
</ul>
85
85
</body>
86
86
</html>
87
87
```
88
88
89
-
...And if we ask for all descendants of `<body>`, then we get direct children `<div>`, `<ul>` and also more nested elements like `<li>` (being a child of `<ul>`) and `<b>` (being a child of `<li>`) -- the entire subtree.
89
+
...E se pedirmos todos os descendentes de `<body>`, obteremos os filhos diretos `<div>`, `<ul>` e também mais elementos aninhados como `<li>` (sendo filho de `<ul>`) e `<b>` (sendo filho de `<li>`) -- a subárvore toda.
90
90
91
-
**The `childNodes` collection provides access to all child nodes, including text nodes.**
91
+
**A coleção `childNodes` fornece acesso a todos os nós filhos, incluindo nós de textos.**
92
92
93
-
The example below shows children of `document.body`:
93
+
O exemplo abaixo mostra os filhos de `document.body`:
94
94
95
95
```html run
96
96
<html>
97
97
<body>
98
-
<div>Begin</div>
98
+
<div>Início</div>
99
99
100
100
<ul>
101
-
<li>Information</li>
101
+
<li>Informação</li>
102
102
</ul>
103
103
104
-
<div>End</div>
104
+
<div>Fim</div>
105
105
106
106
<script>
107
107
*!*
108
108
for (let i = 0; i < document.body.childNodes.length; i++) {
Please note an interesting detail here. If we run the example above, the last element shown is `<script>`. In fact, the document has more stuff below, but at the moment of the script execution the browser did not read it yet, so the script doesn't see it.
118
+
Observe um detalhe interessante aqui. Se executarmos o exemplo acima, o último elemento mostrado é `<script>`. De fato, o documento tem mais informações abaixo, mas no momento da execução do script o navegador ainda não leu os elementos posteriores, portanto o script não os vê.
119
119
120
-
**Properties `firstChild` and `lastChild` give fast access to the first and last children.**
120
+
**As propriedades `firstChild` e `lastChild` fornecem acesso rápido ao primeiro e ao último filho.**
121
121
122
-
They are just shorthands. If there exist child nodes, then the following is always true:
122
+
São apenas abreviações. Se houver nós filhos, o seguinte sempre será verdadeiro:
0 commit comments