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
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,60 +208,60 @@ Por exemplo:
208
208
</script></body></html>
209
209
```
210
210
211
-
## Element-only navigation
211
+
## Navegação apenas por elementos
212
212
213
-
Navigation properties listed above refer to *all* nodes. For instance, in`childNodes` we can see both text nodes, element nodes, and even comment nodes if there exist.
213
+
As propriedades de navegação listadas acima se referem a *todos* os nós. Por exemplo, em`childNodes`, podemos ver nós de textos, nós de elementos e até nós de comentários, se existirem.
214
214
215
-
But for many tasks we don't want text or comment nodes. We want to manipulate element nodes that represent tags and form the structure of the page.
215
+
Mas, para muitas tarefas, não queremos nós de textos ou comentários. Queremos manipular nós de elementos que formam a estrutura da página.
216
216
217
-
So let's see more navigation links that only take *element nodes* into account:
217
+
Então, vamos ver mais interligações de navegação que consideram apenas *nós de elementos*:
218
218
219
219

220
220
221
-
The links are similar to those given above, just with `Element` word inside:
221
+
As interligações são semelhantes às apresentadas acima, acrescentando apenas a palavra `Element`:
222
222
223
-
-`children` -- only those children that are element nodes.
224
-
-`firstElementChild`, `lastElementChild` -- first and last element children.
-`children` -- somente os nós que são filhos do elemento.
224
+
-`firstElementChild`, `lastElementChild` -- primeiro e último elemento filho.
225
+
-`previousElementSibling`, `nextElementSibling` -- elementos vizinhos.
226
+
-`parentElement` -- elemento pai.
227
227
228
-
````smart header="Why `parentElement`? Can the parent be *not* an element?"
229
-
The `parentElement`property returns the "element" parent, while`parentNode`returns "any node" parent. These properties are usually the same: they both get the parent.
228
+
````smart header="Por que `parentElement`? O pai *não* pode ser um elemento?"
229
+
A propriedade `parentElement`retorna o "elemento" pai, enquanto`parentNode`retorna "qualquer nó" pai. Essas propriedades geralmente são as mesmas: ambas obtêm o pai.
230
230
231
-
With the one exception of`document.documentElement`:
In other words, the`documentElement` (`<html>`) is the root node. Formally, it has `document`as its parent. But `document`is not an element node, so `parentNode`returns it and `parentElement`does not.
238
+
Em outras palavras, o`documentElement` (`<html>`) é o nó raiz. Formalmente, tem `document`como pai. Mas o `document`não é um nó de elemento, portanto, somente `parentNode`o retorna. `parentElement`não.
239
239
240
-
This loop travels up from an arbitrary element `elem`to`<html>`, but not to the`document`:
240
+
Este laço de repetição percorre de um elemento arbitrário `elem`até`<html>`, mas não até o`document`:
241
241
```js
242
242
while(elem =elem.parentElement) {
243
-
alert( elem ); //parent chain till <html>
243
+
alert( elem ); //sequência de pais até <html>
244
244
}
245
245
```
246
246
````
247
247
248
-
Let's modify one of the examples above: replace `childNodes` with `children`. Now it shows only elements:
248
+
Vamos modificar um dos exemplos acima: substitua `childNodes` por `children`. Agora ele mostra apenas elementos:
0 commit comments