Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
palak1008jain authored Nov 19, 2023
1 parent 141797b commit 1d69ee9
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const buttons = document.querySelectorAll('.button');
const body = document.querySelector('body');

console.log(buttons);

buttons.forEach(function(button){
button.addEventListener('click', function(e){
console.log(e.target);
if (e.target.id === 'grey'){
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'white'){
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'blue'){
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'yellow'){
body.style.backgroundColor = e.target.id;
}
})
})
Binary file added color change.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>JavaScript Background Color Switcher</title>
</head>
<body>
<div class="canvas">
<h1>Color Scheme Switcher</h1>
<span class="button" id="grey"></span>
<span class="button" id="white"></span>
<span class="button" id="blue"></span>
<span class="button" id="yellow"></span>
<h2>Try clicking on one of the colors above <span>to change the background color of this page!</span></h2>
</div>
<script src="app.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
html {
margin: 0;
}

span {
display: block;
}
.canvas {
margin: 100px auto 100px;
width: 80%;
text-align: center;
}

.button {
width: 100px;
height: 100px;
border: solid black 2px;
display: inline-block;
border-radius: 50%;
}

#grey{
background: grey;
}

#white{
background: white;
}
#blue{
background: blue;
}
#yellow{
background: yellow;
}

0 comments on commit 1d69ee9

Please sign in to comment.