-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (42 loc) · 1.09 KB
/
index.html
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
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<style>
.clicked {
background-color: blue;
}
</style>
</body>
<script>
let h1 = document.createElement('h1');
let body = document.body;
let text = document.createTextNode('hi');
document.create
h1.append(text);
body.append(h1);
let ul = document.createElement('ul');
const alpha = 'abcdefghijklmnopqrstuvwxyz'
for (let letter of alpha) {
let li = document.createElement('li')
// either one of the below works: access attributes directly since they already have a place
// li.setAttribute('id', letter)
li.id = letter;
li.addEventListener('click', () => {
li.classList.toggle('clicked')
})
li.append(letter)
ul.append(li);
}
body.append(ul);
// css selector
let a = document.querySelector('#a');
ul.removeChild(a);
let style = document.querySelector('style')
</script>
</html>