-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor1.html
More file actions
26 lines (25 loc) · 876 Bytes
/
Copy pathcolor1.html
File metadata and controls
26 lines (25 loc) · 876 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>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Color 0</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
document.addEventListener('DOMContentLoaded',function(){
//changes color to red
document.querySelectorAll('.color-change').forEach(function(button){
button.onclick = function () {
document.querySelector('#hello').style.color = button.dataset.color;
}
});
});
</script>
</head>
<body>
<h1 id="hello">Hello!</h1>
<button class="color-change" data-color="Red">Red</button>
<button class="color-change" data-color="Blue">Blue</button>
<button class="color-change" data-color="Green">Green</button>
</body>
</html>