Skip to content

Commit e26b59e

Browse files
authored
Merge pull request #323 from vplentinax/domatt
Attributes and properties
2 parents e67f340 + 8fbe8d5 commit e26b59e

File tree

7 files changed

+175
-176
lines changed

7 files changed

+175
-176
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<html>
55
<body>
66

7-
<div data-widget-name="menu">Choose the genre</div>
7+
<div data-widget-name="menu">Elige el género</div>
88

99
<script>
10-
// getting it
10+
// obteniéndolo
1111
let elem = document.querySelector('[data-widget-name]');
1212
13-
// reading the value
13+
// leyendo el valor
1414
alert(elem.dataset.widgetName);
15-
// or
15+
// o
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ importance: 5
22

33
---
44

5-
# Get the attribute
5+
# Obtén en atributo
66

7-
Write the code to select the element with `data-widget-name` attribute from the document and to read its value.
7+
Escribe el código para obtener el atributo `data-widget-name` del documento y leer su valor.
88

99
```html run
1010
<!DOCTYPE html>
1111
<html>
1212
<body>
1313

14-
<div data-widget-name="menu">Choose the genre</div>
14+
<div data-widget-name="menu">Elige el genero</div>
1515

1616
<script>
17-
/* your code */
17+
/* Tu código */
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+
Primero, necesitamos encontrar todos los enlaces externos.
33

4-
There are two ways.
4+
Hay dos.
55

6-
The first is to find all links using `document.querySelectorAll('a')` and then filter out what we need:
6+
El primero es encontrar todos los enlaces usando `document.querySelectorAll('a')` y luego filtrar lo que necesitamos:
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; // no atributo
1616

17-
if (!href.includes('://')) continue; // no protocol
17+
if (!href.includes('://')) continue; // no protocolo
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+
Tenga en cuenta: nosotros usamos `link.getAttribute('href')`. No `link.href`, porque necesitamos el valor del HTML.
2626

27-
...Another, simpler way would be to add the checks to CSS selector:
27+
...Otra forma más simple sería agregar las comprobaciones al selector CSS:
2828

2929
```js
30-
// look for all links that have :// in href
31-
// but href doesn't start with http://internal.com
30+
// busque todos los enlaces que tengan: // en href
31+
//pero href no comienza 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/solution.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<body>
44

5-
<a name="list">The list:</a>
5+
<a name="list">La lista:</a>
66
<ul>
77
<li><a href="http://google.com">http://google.com</a></li>
88
<li><a href="/tutorial">/tutorial.html</a></li>

2-ui/1-document/06-dom-attributes-and-properties/2-yellow-links/source.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<body>
44

5-
<a name="list">The list:</a>
5+
<a name="list">La lista</a>
66
<ul>
77
<li><a href="http://google.com">http://google.com</a></li>
88
<li><a href="/tutorial">/tutorial.html</a></li>
@@ -13,7 +13,7 @@
1313
</ul>
1414

1515
<script>
16-
// ...your code...
16+
// ...Tu código...
1717
</script>
1818

1919
</body>

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+
# Haz los enlaces externos naranjas
66

7-
Make all external links orange by altering their `style` property.
7+
Haz todos los enlaces externos de color orange alterando su propiedad `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 es externo si:
10+
- Su `href` tiene `://`
11+
- Pero no comienza con `http://internal.com`.
1212

13-
Example:
13+
Ejemplo:
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+
// establecer un estilo para un enlace
2828
let link = document.querySelector('a');
2929
link.style.color = 'orange';
3030
</script>
3131
```
3232

33-
The result should be:
33+
El resultado podría ser:
3434

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

0 commit comments

Comments
 (0)