File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > JavaScript: Quote sample</ title >
6+
7+ </ head >
8+
9+ < body >
10+
11+ < main >
12+ < article >
13+ < h1 > Dagens citat</ h1 >
14+ < p id ="citat "> </ p >
15+ </ article >
16+ < article >
17+ < h1 > Overskrift</ h1 >
18+ < p > Tekst</ p >
19+ < img src ="" alt ="">
20+ </ article >
21+ </ main >
22+ < script >
23+ let citater = [
24+ "A horse, a horse, my kingdom for a horse." ,
25+ "Every man and every woman is a star." ,
26+ "The fatal glass of beer." ,
27+ "Sometimes it snows in April." ,
28+ "Here comes the Sun." ,
29+ "Purple Rain"
30+ ] ;
31+
32+ // vælger en id
33+ let tekst = document . getElementById ( "citat" ) ;
34+
35+ // tilfældigt nummer
36+ let x = Math . floor ( Math . random ( ) * citater . length ) ;
37+
38+ // viser citatet
39+ tekst . innerHTML = citater [ x ] ;
40+
41+ // udfordring: skift citat ved event
42+
43+ // udfordring: skift citat via en timer-funktion
44+ // se: https://www.w3schools.com/jsref/met_win_settimeout.asp
45+
46+ // udfordring: lav en liste med 7 citater, vis samme citat hver mandag etc.
47+ </ script >
48+
49+
50+ </ body >
51+ </ html >
You can’t perform that action at this time.
0 commit comments