-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom-practice.html
More file actions
50 lines (32 loc) · 1.02 KB
/
dom-practice.html
File metadata and controls
50 lines (32 loc) · 1.02 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Create an HTML file called dom-practice.html in codeup-web-exercises repos.
Put a text input on an html page with id of “color”
Put a button on the page with id of “changeColor”
Use an Event listener to trigger when the button is clicked.
Use the value to change the background-color of the page to match the user’s input value.
example of input: “#00000”, “black”, “#FF00FF
<p id="color">
Color
</p>
<button id="changeColor"></button>
</body>
<script>
var coloredText = document.getElementById('color')
var button = document.getElementById('changeColor')
var listener = function changeColor() {
coloredText.style.color = "blue";
}
button.addEventListener("click", listener)
var body = document.querySelector("body");
button.addEventListener("click", function changeColore(e) {
body.style.backgroundColor = color.value
})
</script>
</body>
</html>