-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelements.html
More file actions
53 lines (36 loc) · 1.01 KB
/
elements.html
File metadata and controls
53 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.hidden {
text-decoration: line-through;
}
</style>
</head>
<body>
<script>
let heading = document.createElement('h1');
let message = document.createTextNode('Hello World');
heading.appendChild(message);
console.log(heading);
let body = document.getElementsByTagName('body');
body[0].appendChild(heading);
console.log(body);
let week = document.createElement("ul");
week.addEventListener('click', hide);
body[0].appendChild(week);
let days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturay", "Sunday"];
days.forEach(function(dayName) {
let day = document.createElement("li");
day.innerText = dayName;
week.appendChild(day);
})
function hide(event) {
console.log('hiding a day of the week: ' + event.target.innerText);
event.target.classList.toggle('hidden');
}
</script>
</body>
</html>