-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolors.html
More file actions
26 lines (26 loc) · 814 Bytes
/
colors.html
File metadata and controls
26 lines (26 loc) · 814 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colors</title>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelector('#red').onclick = function() {
document.querySelector('h1').style.color = 'red';
}
document.querySelector('#black').onclick = function() {
document.querySelector('h1').style.color = 'black';
}
document.querySelector('#green').onclick = function() {
document.querySelector('h1').style.color = 'green';
}
})
</script>
</head>
<body>
<h1 style="color: blue">This will change when you click one of the buttons below</h1>
<button id="red">Red</button>
<button id="black">Black</button>
<button id="green">Green</button>
</body>
</html>