-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorPicker2.html
More file actions
51 lines (46 loc) · 1.67 KB
/
colorPicker2.html
File metadata and controls
51 lines (46 loc) · 1.67 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
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Updated Color Picker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="row">
<label for="bg">Background</label>
<input type="color" id="bg" value="#FFFFFF">
</div>
<div class="row">
<label for="txt">Text</label>
<input type="color" id="txt">
</div>
<button id="clear">CLEAR</button>
</div>
</div>
<script>
const content = document.querySelector('.content');
const bg = document.getElementById('bg');
const txt = document.getElementById('txt');
const clear = document.getElementById('clear');
bg.addEventListener('change', function(e){
content.style.backgroundColor = e.target.value;
});
txt.addEventListener('change', function(e){
content.style.color=e.target.value;
});
clear.addEventListener('click', function(){
content.style.backgroundColor = 'white';
bg.value = '#FFFFFF';
content.style.color='black';
txt.value = '#000000';
});
</script>
</body>
</html>