Skip to content

Commit 7b1ea9e

Browse files
authored
Merge pull request #267 from Dorin-David/attributes-and-properties
Attributes and properties
2 parents 139c9f0 + 897f499 commit 7b1ea9e

File tree

5 files changed

+145
-143
lines changed

5 files changed

+145
-143
lines changed

2-ui/1-document/06-dom-attributes-and-properties/1-get-user-attribute/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<div data-widget-name="menu">Choose the genre</div>
88

99
<script>
10-
// getting it
10+
// trovalo
1111
let elem = document.querySelector('[data-widget-name]');
1212
13-
// reading the value
13+
// leggi il valore
1414
alert(elem.dataset.widgetName);
15-
// or
15+
// oppure
1616
alert(elem.getAttribute('data-widget-name'));
1717
</script>
1818
</body>

2-ui/1-document/06-dom-attributes-and-properties/1-get-user-attribute/task.md

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

33
---
44

5-
# Get the attribute
5+
# Trova l'attributo
66

7-
Write the code to select the element with `data-widget-name` attribute from the document and to read its value.
7+
Scrivi il codice per selezionare e leggere il valore degli elementi del documento con l'attributo `data-widget-name`.
88

99
```html run
1010
<!DOCTYPE html>
@@ -14,7 +14,7 @@ Write the code to select the element with `data-widget-name` attribute from the
1414
<div data-widget-name="menu">Choose the genre</div>
1515

1616
<script>
17-
/* your code */
17+
/* il tuo codice */
1818
</script>
1919
</body>
2020
</html>

2-ui/1-document/06-dom-attributes-and-properties/2-yellow-links/solution.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
First, we need to find all external references.
2+
Prima di tutto, dobbiamo trovare tutte le referenze esterne.
33

4-
There are two ways.
4+
Ci sono due modi.
55

6-
The first is to find all links using `document.querySelectorAll('a')` and then filter out what we need:
6+
Il primo è quello di trovare tutti i link utilizzando `document.querySelectorAll('a')` e poi filtrare quelli che ci servono:
77

88
```js
99
let links = document.querySelectorAll('a');
@@ -12,23 +12,23 @@ for (let link of links) {
1212
*!*
1313
let href = link.getAttribute('href');
1414
*/!*
15-
if (!href) continue; // no attribute
15+
if (!href) continue; // nessun attributo
1616

17-
if (!href.includes('://')) continue; // no protocol
17+
if (!href.includes('://')) continue; // nessun protocollo
1818

19-
if (href.startsWith('http://internal.com')) continue; // internal
19+
if (href.startsWith('http://internal.com')) continue; // interno
2020

2121
link.style.color = 'orange';
2222
}
2323
```
2424

25-
Please note: we use `link.getAttribute('href')`. Not `link.href`, because we need the value from HTML.
25+
Nota: utilizziamo `link.getAttribute('href')`, non `link.href`, perché abbiamo bisogno del valore dall'HTML.
2626

27-
...Another, simpler way would be to add the checks to CSS selector:
27+
...Un'altra, più semplice alternativa sarebbe aggiungere dei controlli ai selettori CSS:
2828

2929
```js
30-
// look for all links that have :// in href
31-
// but href doesn't start with http://internal.com
30+
// cerca tutti i link che hanno :// in href
31+
// ma href non inizia con http://internal.com
3232
let selector = 'a[href*="://"]:not([href^="http://internal.com"])';
3333
let links = document.querySelectorAll(selector);
3434

2-ui/1-document/06-dom-attributes-and-properties/2-yellow-links/task.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ importance: 3
22

33
---
44

5-
# Make external links orange
5+
# Rendi tutti i link esterni arancioni
66

7-
Make all external links orange by altering their `style` property.
7+
Rendi tutti i link esterni arancioni modificandone la proprietà `style`.
88

9-
A link is external if:
10-
- Its `href` has `://` in it
11-
- But doesn't start with `http://internal.com`.
9+
Un link è esterno se:
10+
- Il suo `href` ha `://`
11+
- Ma non comincia con `http://internal.com`.
1212

13-
Example:
13+
Esempio:
1414

1515
```html run
1616
<a name="list">the list</a>
@@ -24,12 +24,12 @@ Example:
2424
</ul>
2525

2626
<script>
27-
// setting style for a single link
27+
// imposta lo stile per un singolo link
2828
let link = document.querySelector('a');
2929
link.style.color = 'orange';
3030
</script>
3131
```
3232

33-
The result should be:
33+
Il risultato dovrebbe essere:
3434

3535
[iframe border=1 height=180 src="solution"]

0 commit comments

Comments
 (0)