Skip to content

Commit 36f067c

Browse files
committed
add novos exercicios sobre propriedade e atributos API DOM
1 parent 9334e5b commit 36f067c

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

EXE_API_DOM/get-the-attribute.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
</head>
7+
<body>
8+
9+
<div data-widget-name="menu">Choose the genre</div>
10+
11+
<script type="text/javascript">
12+
13+
/**
14+
* Escreva o código para selecionar o elemento com data-widget-name atributo do documento e ler seu valor.
15+
*/
16+
17+
let div = document.body.firstElementChild;
18+
19+
console.log(div.dataset.widgetName); //menu
20+
21+
console.log(div.getAttribute('data-widget-name')); //menu
22+
23+
</script>
24+
25+
</body>
26+
27+
</html>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
</head>
7+
<body>
8+
9+
<a name="list">the list</a>
10+
<ul>
11+
<li><a href="http://google.com">http://google.com</a></li>
12+
<li><a href="/tutorial">/tutorial.html</a></li>
13+
<li><a href="local/path">local/path</a></li>
14+
<li><a href="ftp://ftp.com/my.zip">ftp://ftp.com/my.zip</a></li>
15+
<li><a href="http://nodejs.org">http://nodejs.org</a></li>
16+
<li><a href="http://internal.com/test">http://internal.com/test</a></li>
17+
</ul>
18+
19+
<div data-widget-name="menu">Choose the genre</div>
20+
21+
<script type="text/javascript">
22+
23+
/**
24+
* Torne todos os links externos laranja alterando suas style propriedades.
25+
*
26+
* Um link é externo se:
27+
28+
- Seu href tem :// nele
29+
30+
- Mas não começa com http://internal.com.
31+
*/
32+
33+
34+
//estilo de configuração para um único link
35+
let allLinks = document.querySelectorAll('a');
36+
37+
for(let link of allLinks) {
38+
if(link.getAttribute('href') != null) {
39+
if(link.getAttribute('href').includes('://') && link.getAttribute('href').startsWith('http://internal.com') == false) {
40+
link.style.color = 'orange';
41+
}
42+
}
43+
}
44+
</script>
45+
46+
</body>
47+
</html>

0 commit comments

Comments
 (0)