-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolors3.html
More file actions
22 lines (22 loc) · 735 Bytes
/
colors3.html
File metadata and controls
22 lines (22 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colors 3 - with arrow notation</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('button').forEach(function(button) {
button.onclick = () => {
document.querySelector('#hello').style.color = button.dataset.color;
}
})
})
</script>
</head>
<body>
<h1 id="hello" style="color: blue">This will change when you click one of the buttons below</h1>
<button class="change-color" data-color="red">Red</button>
<button class="change-color" data-color="black">Black</button>
<button class="change-color" data-color="green">Green</button>
</body>
</html>