diff --git a/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md b/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md index c73aecd99..062bc7c4a 100644 --- a/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md +++ b/2-ui/1-document/04-searching-elements-dom/1-find-elements/solution.md @@ -1,35 +1,35 @@ -There are many ways to do it. +Ci sono molti modi per farlo. -Here are some of them: +Eccone alcuni: ```js -// 1. The table with `id="age-table"`. +// 1. La tabella con `id="age-table"`. let table = document.getElementById('age-table') -// 2. All label elements inside that table +// 2. Tutti gli elementi label dentro la tabella table.getElementsByTagName('label') -// or +// oppure document.querySelectorAll('#age-table label') -// 3. The first td in that table (with the word "Age") +// 3. Il primo td dentro la tabella (con la parola "Age") table.rows[0].cells[0] -// or +// oppure table.getElementsByTagName('td')[0] -// or +// oppure table.querySelector('td') -// 4. The form with the name "search" -// assuming there's only one element with name="search" in the document +// 4. La form con il nome "search" +// supponendo ci sia solo un elemento con name="search" nel documento let form = document.getElementsByName('search')[0] -// or, form specifically +// oppure, form specificamente document.querySelector('form[name="search"]') -// 5. The first input in that form. +// 5. Il primo input contenuto in form. form.getElementsByTagName('input')[0] -// or +// oppure form.querySelector('input') -// 6. The last input in that form -let inputs = form.querySelectorAll('input') // find all inputs -inputs[inputs.length-1] // take the last one +// 6. L'ultimo input in form +let inputs = form.querySelectorAll('input') // trova tutti gli input +inputs[inputs.length-1] // prendi l'ultimo ``` diff --git a/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md b/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md index f0b54beac..cde00842d 100644 --- a/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md +++ b/2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md @@ -2,17 +2,17 @@ importance: 4 --- -# Search for elements +# Ricerca degli elementi -Here's the document with the table and form. +Abbiamo un documento con una tabella e un form. -How to find?... +Come trovare?... -1. The table with `id="age-table"`. -2. All `label` elements inside that table (there should be 3 of them). -3. The first `td` in that table (with the word "Age"). -4. The `form` with `name="search"`. -5. The first `input` in that form. -6. The last `input` in that form. +1. La tabella con `id="age-table"`. +2. Tutti gli elementi `label` dentro la tabella (dovrebbero essercene 3). +3. Il primo `td` nella tabella (con la parola "Age"). +4. Il `form` con `name="search"`. +5. Il primo `input` nel form. +6. L'ultimo `input` nel form. -Open the page [table.html](table.html) in a separate window and make use of browser tools for that. +Apri la pagina [table.html](table.html) in un'altra finestra e utilizza gli strumenti del browser. diff --git a/2-ui/1-document/04-searching-elements-dom/article.md b/2-ui/1-document/04-searching-elements-dom/article.md index 5af6435ce..d7f1911df 100644 --- a/2-ui/1-document/04-searching-elements-dom/article.md +++ b/2-ui/1-document/04-searching-elements-dom/article.md @@ -1,14 +1,14 @@ -# Searching: getElement*, querySelector* +# Ricerca: getElement*, querySelector* -DOM navigation properties are great when elements are close to each other. What if they are not? How to get an arbitrary element of the page? +Le proprietà di navigazione del DOM funzionano bene per gli elementi vicini. E quando non lo sono? Come possiamo ottenere un elemento arbitrario della pagina? -There are additional searching methods for that. +Ci sono altri metodi di ricerca per questo. -## document.getElementById or just id +## document.getElementById o semplicemente id -If an element has the `id` attribute, we can get the element using the method `document.getElementById(id)`, no matter where it is. +Se un elemento ha un attributo `id` possiamo trovarlo, ovunque esso sia, utilizzando il metodo `document.getElementById(id)` -For instance: +Ad esempio: ```html run
Method | -Searches by... | -Can call on an element? | -Live? | +Metodo | +Cerca tramite... | +Può essere chiamato su un elemento? | +Vivo? |
getElementsByTagName |
-tag or '*' |
+tag o '*' |
✔ | ✔ | |||
getElementsByClassName |
-class | +classe | ✔ | ✔ |