Skip to content

Commit 2cc8457

Browse files
committed
Update 2-ui/1-document/05-basic-dom-node-properties
1 parent c2dfff7 commit 2cc8457

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
Let's make a loop over `<li>`:
1+
Effettuiamo un ciclo iterativo sugli elementi `<li>`:
22

33
```js
44
for (let li of document.querySelectorAll('li')) {
55
...
66
}
77
```
88

9-
In the loop we need to get the text inside every `li`.
9+
Durante le iterazioni abbiamo bisogno di ricavare il testo all'interno di ogni `li`.
1010

11-
We can read the text from the first child node of `li`, that is the text node:
11+
Possiamo leggere il testo dal primo nodo figlio di `li` che è un nodo di testo:
1212

1313
```js
1414
for (let li of document.querySelectorAll('li')) {
1515
let title = li.firstChild.data;
1616

17-
// title is the text in <li> before any other nodes
17+
// title è il testo nel <li> prima di qualsiasi altro nodo
1818
}
1919
```
2020

21-
Then we can get the number of descendants as `li.getElementsByTagName('li').length`.
21+
A questo punto possiamo ricavare il numero dei discendenti con `li.getElementsByTagName('li').length`.

2-ui/1-document/05-basic-dom-node-properties/2-tree-info/solution.view/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141

4242
<script>
4343
for (let li of document.querySelectorAll('li')) {
44-
// get the title from the text node
44+
// ricava il titolo dal nodo di testo
4545
let title = li.firstChild.data;
4646

47-
title = title.trim(); // remove extra spaces from ends
47+
title = title.trim(); // rimuove gli spazi bianchi all'inizio e alla fine
4848

49-
// get the descendants count
49+
// ottiene il numero dei discendenti
5050
let count = li.getElementsByTagName('li').length;
5151

5252
alert(title + ': ' + count);

2-ui/1-document/05-basic-dom-node-properties/2-tree-info/source.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</ul>
4141

4242
<script>
43-
// ... your code...
43+
// ... il tuo codice ...
4444
</script>
4545

4646
</body>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
importance: 5
1+
importanza: 5
22

33
---
44

5-
# Count descendants
5+
# Contate i discendenti
66

7-
There's a tree structured as nested `ul/li`.
7+
Abbiamo un alberatura HTML strutturata come un elenco di `ul/li` annidati.
88

9-
Write the code that for each `<li>` shows:
9+
Scrivete il codice che per ogni elemento `<li>` mostri:
1010

11-
1. What's the text inside it (without the subtree)
12-
2. The number of nested `<li>` -- all descendants, including the deeply nested ones.
11+
1. Qual è il testo al suo interno (senza considerare l'eventuale sottostruttura)
12+
2. Il numero degli elementi `<li>` annidati -- tutti i discendenti, considerando tutti i livelli di annidamento.
1313

1414
[demo src="solution"]

2-ui/1-document/05-basic-dom-node-properties/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,4 +495,4 @@ Le principali proprietà di un nodo DOM sono:
495495
496496
I nodi del DOM hanno inoltre altre proprietà in base alla loro classe di appartenenza. Per esempio gli elementi `<input>` (`HTMLInputElement`) supportano `value`, `type`, mentre gli elementi `<a>` (`HTMLAnchorElement`) supportano `href` etc. La maggior parte degli attributi HTML standard hanno una proprietà DOM corrispondente.
497497
498-
However, HTML attributes and DOM properties are not always the same, as we'll see in the next chapter.
498+
Ad ogni modo, come vedremo nel prossimo capitolo, gli attributi HTML e le proprietà del DOM non sono sempre corrispondenti.

0 commit comments

Comments
 (0)