Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishaxKumari committed Jun 14, 2024
0 parents commit d0b3af4
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
21 changes: 21 additions & 0 deletions ColorChanger/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">
<title>color changer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="canva">
<h1>click for color change</h1>
<span class="button" id="white"></span>
<span class="button" id="yellow"></span>
<span class="button" id="red"></span>
<span class="button" id="green"></span>
</div>

<script src="logic.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions ColorChanger/logic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const buttons=document.querySelectorAll('.button');
const body=document.querySelector('body');

buttons.forEach(function(button){
button.addEventListener('click',function(e){
if (e.target.id === 'green') {
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'white') {
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'red') {
body.style.backgroundColor = e.target.id;
}
if (e.target.id === 'yellow') {
body.style.backgroundColor = e.target.id;
}
});
});
36 changes: 36 additions & 0 deletions ColorChanger/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*{
padding:0px;
margin: 0px;

}

span{
display: block;
}

.canva{
margin: 100px;
width: 80%;
text-align: center;
}
.button {
width: 100px;
height: 100px;
border: solid black 2px;
display: inline-block;
}

#green {
background: green;
}

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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# beginner-javascript-project

0 comments on commit d0b3af4

Please sign in to comment.