File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed
Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments