-
Notifications
You must be signed in to change notification settings - Fork 0
/
changingCSS.html
35 lines (32 loc) · 1.11 KB
/
changingCSS.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Changing CSS with JavaScript</h1>
<div>
<label>Bg Color: </label>
<input type = "text" class = "btn-bg-color" style = 'padding:30px; font-size: 30px;'></input>
</div>
<div>
<label>Text Color: </label>
<input type = "text" class = "btn-text-color" style = 'padding:30px; font-size: 30px;'></input>
</div>
<script>
var body = document.querySelector("body")
var bgColor = document.querySelector(".btn-bg-color")
var textColor = document.querySelector(".btn-text-color")
bgColor.addEventListener('keyup', function(event){
var color = event.target.value
body.style.backgroundColor = color
})
textColor.addEventListener('keyup', function(event){
var color = event.target.value
body.style.color = color
})
</script>
</body>
</html>