Skip to content

Commit 35d7d53

Browse files
authored
Merge pull request #311 from elemarmar/search-elements-dom-emm
Searching: getElement*, querySelector*
2 parents 17864bb + ee7670b commit 35d7d53

File tree

4 files changed

+136
-137
lines changed

4 files changed

+136
-137
lines changed
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
There are many ways to do it.
1+
Hay muchas maneras de resolverlo.
22

3-
Here are some of them:
3+
Aquí hay algunas de ellas:
44

55
```js
6-
// 1. The table with `id="age-table"`.
6+
// 1. La tabla con `id="age-table"`.
77
let table = document.getElementById('age-table')
88

9-
// 2. All label elements inside that table
9+
// 2. Todos los elementos `label` dentro de esa tabla
1010
table.getElementsByTagName('label')
1111
// or
1212
document.querySelectorAll('#age-table label')
1313

14-
// 3. The first td in that table (with the word "Age")
14+
// 3. El primer `td` en la tabla (con la palabra "Age")
1515
table.rows[0].cells[0]
1616
// or
1717
table.getElementsByTagName('td')[0]
1818
// or
1919
table.querySelector('td')
2020

21-
// 4. The form with the name "search"
22-
// assuming there's only one element with name="search" in the document
21+
// 4. El `form` con name="search"
22+
// suponiendo que sólo hay un elemento con name="search" en el documento
2323
let form = document.getElementsByName('search')[0]
24-
// or, form specifically
24+
//o, utilizando el form específicamente
2525
document.querySelector('form[name="search"]')
2626

27-
// 5. The first input in that form.
27+
// 5. El primer input en el form.
2828
form.getElementsByTagName('input')[0]
29-
// or
29+
// o
3030
form.querySelector('input')
3131

32-
// 6. The last input in that form
33-
let inputs = form.querySelectorAll('input') // find all inputs
34-
inputs[inputs.length-1] // take the last one
32+
// 6. El último input en el form.
33+
let inputs = form.querySelectorAll('input') // encontrar todos los inputs
34+
inputs[inputs.length-1] // obtener el último
3535
```

2-ui/1-document/04-searching-elements-dom/1-find-elements/table.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<body>
44
<form name="search">
5-
<label>Search the site:
5+
<label>Buscar en la página:
66
<input type="text" name="search">
77
</label>
88
<input type="submit" value="Search!">
@@ -11,22 +11,22 @@
1111
<hr>
1212

1313
<form name="search-person">
14-
Search the visitors:
14+
Buscar a los visitantes:
1515
<table id="age-table">
1616
<tr>
17-
<td>Age:</td>
17+
<td>Edad:</td>
1818
<td id="age-list">
1919
<label>
20-
<input type="radio" name="age" value="young">less than 18</label>
20+
<input type="radio" name="age" value="young">menor de 18</label>
2121
<label>
2222
<input type="radio" name="age" value="mature">18-50</label>
2323
<label>
24-
<input type="radio" name="age" value="senior">more than 50</label>
24+
<input type="radio" name="age" value="senior">mayor de 50</label>
2525
</td>
2626
</tr>
2727

2828
<tr>
29-
<td>Additionally:</td>
29+
<td>Más:</td>
3030
<td>
3131
<input type="text" name="info[0]">
3232
<input type="text" name="info[1]">

2-ui/1-document/04-searching-elements-dom/1-find-elements/task.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ importance: 4
22

33
---
44

5-
# Search for elements
5+
# Buscar elementos
6+
Aquí está el documento con la tabla y el formulario.
67

7-
Here's the document with the table and form.
8+
¿Cómo encontrar?...
89

9-
How to find?...
10+
1. La tabla con `id="age-table"`.
11+
2. Todos los elementos `label`dentro de la tabla (debería haber 3).
12+
3. El primer `td` en la tabla (con la palabra "Age").
13+
4. El `form` con `name="search"`.
14+
5. El primer `input` en ese formulario.
15+
6. El último `input` en ese formulario.
1016

11-
1. The table with `id="age-table"`.
12-
2. All `label` elements inside that table (there should be 3 of them).
13-
3. The first `td` in that table (with the word "Age").
14-
4. The `form` with `name="search"`.
15-
5. The first `input` in that form.
16-
6. The last `input` in that form.
17-
18-
Open the page [table.html](table.html) in a separate window and make use of browser tools for that.
17+
Abra la página [table.html](table.html) en una ventana separada y haga uso de las herramientas del navegador.

0 commit comments

Comments
 (0)