-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolors0.html
More file actions
31 lines (28 loc) · 1021 Bytes
/
colors0.html
File metadata and controls
31 lines (28 loc) · 1021 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
27
28
29
30
31
<!DOCTYPE html>
<html>
<head>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Change font color to red
document.querySelector('#red').onclick = function() {
document.querySelector('#hello').style.color = 'red';
};
// Change font color to blue
document.querySelector('#blue').onclick = function() {
document.querySelector('#hello').style.color = 'blue';
};
// Change font color to green
document.querySelector('#green').onclick = function() {
document.querySelector('#hello').style.color = 'green';
};
});
</script>
<title>My Website</title>
</head>
<body>
<h1 id="hello">Hello!</h1>
<button id="red">Red</button>
<button id="blue">Blue</button>
<button id="green">Green</button>
</body>
</html>