Skip to content

Commit b29198c

Browse files
authored
Merge pull request #253 from pasor1/article/03-dom-navigation
Walking the DOM
2 parents 9136694 + 042060b commit b29198c

File tree

8 files changed

+144
-143
lines changed

8 files changed

+144
-143
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
There are many ways, for instance:
1+
E' possibile farlo in diversi modi, ad esempio:
22

33

4-
The `<div>` DOM node:
4+
Il nodo DOM `<div>`:
55

66
```js
77
document.body.firstElementChild
8-
// or
8+
// oppure
99
document.body.children[0]
10-
// or (the first node is space, so we take 2nd)
10+
// oppure (il primo nodo è uno spazio, quindi prendiamo il secondo)
1111
document.body.childNodes[1]
1212
```
1313

14-
The `<ul>` DOM node:
14+
Il nodo DOM `<ul>`:
1515

1616
```js
1717
document.body.lastElementChild
18-
// or
18+
// oppure
1919
document.body.children[1]
2020
```
2121

22-
The second `<li>` (with Pete):
22+
Il secondo `<li>` (con Pete):
2323

2424
```js
25-
// get <ul>, and then get its last element child
25+
// prendi <ul>, e quindi il suo ultimo elemento figlio
2626
document.body.lastElementChild.lastElementChild
2727
```

2-ui/1-document/03-dom-navigation/1-dom-children/task.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ importance: 5
22

33
---
44

5-
# DOM children
5+
# Figli nel DOM
66

7-
Look at this page:
7+
Guardiamo questa pagina:
88

99
```html
1010
<html>
1111
<body>
12-
<div>Users:</div>
12+
<div>Utenti:</div>
1313
<ul>
1414
<li>John</li>
1515
<li>Pete</li>
@@ -18,7 +18,7 @@ Look at this page:
1818
</html>
1919
```
2020

21-
For each of the following, give at least one way of how to access them:
22-
- The `<div>` DOM node?
23-
- The `<ul>` DOM node?
24-
- The second `<li>` (with Pete)?
21+
Per ciascuno dei seguenti, fornire almeno un modo per accedervi:
22+
- Il nodo DOM `<div>` ?
23+
- Il nodo DOM `<ul>` ?
24+
- Il secondo `<li>` (con Pete)?
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
1. Yes, true. The element `elem.lastChild` is always the last one, it has no `nextSibling`.
2-
2. No, wrong, because `elem.children[0]` is the first child *among elements*. But there may exist non-element nodes before it. So `previousSibling` may be a text node.
1+
1. Si, è vero. L'elemento `elem.lastChild` è sempre l'ultimo, non ha `nextSibling`.
2+
2. No, è falso, perché `elem.children[0]` è il primo figlio tra i nodi di tipo *elemento*, ma potrebbero esserci nodi di tipo diverso. Ad esempio `previousSibling` potrebbe essere un nodo di testo.
33

4-
Please note: for both cases if there are no children, then there will be an error.
4+
Nota: in entrambi i casi, se non ci sono figli si verificherà un errore.
55

6-
If there are no children, `elem.lastChild` is `null`, so we can't access `elem.lastChild.nextSibling`. And the collection `elem.children` is empty (like an empty array `[]`).
6+
Se non ci sono figli, `elem.lastChild` è `null`, quindi non possiamo accedere a `elem.lastChild.nextSibling`. E la collection `elem.children` sarà vuota (come un array vuoto `[]`).

2-ui/1-document/03-dom-navigation/3-navigation-links-which-null/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# The sibling question
5+
# La questione dei fratelli
66

7-
If `elem` -- is an arbitrary DOM element node...
7+
Se `elem` è un nodo arbitrario del DOM...
88

9-
- Is it true that `elem.lastChild.nextSibling` is always `null`?
10-
- Is it true that `elem.children[0].previousSibling` is always `null` ?
9+
- E' vero che `elem.lastChild.nextSibling` è sempre `null`?
10+
- E' vero che `elem.children[0].previousSibling` è sempre `null`?
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
We'll be using `rows` and `cells` properties to access diagonal table cells.
1+
Useremo le proprietà `rows` e `cells` per accedere alle celle sulla diagonale della tabella.

2-ui/1-document/03-dom-navigation/4-select-diagonal-cells/source.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<script>
5555
let table = document.body.firstElementChild;
5656

57-
// your code
57+
// il tuo codice
5858
</script>
5959
</body>
6060
</html>

2-ui/1-document/03-dom-navigation/4-select-diagonal-cells/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Select all diagonal cells
5+
# Seleziona tutte le celle sulla diagonale
66

7-
Write the code to paint all diagonal table cells in red.
7+
Scrivi il codice per evidenziare in rosso tutte celle sulla diagonale della tabella.
88

9-
You'll need to get all diagonal `<td>` from the `<table>` and paint them using the code:
9+
Dovrai estrarre tutte i `<td>` in diagonale da `<table>` ed evidenziarli usando il codice:
1010

1111
```js
12-
// td should be the reference to the table cell
12+
// td dovrebbe essere il riferimento alla cella della tabella
1313
td.style.backgroundColor = 'red';
1414
```
1515

16-
The result should be:
16+
Il risultato dovrebbe essere:
1717

1818
[iframe src="solution" height=180]

0 commit comments

Comments
 (0)