Skip to content

Commit

Permalink
Create one-button-game.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh-jot authored Oct 5, 2021
1 parent d4fb249 commit 885fd57
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions one-button-game.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

<script>
const colors = ["yellow", "red", "blue", "green", "purple", "orange", "grey", "cyan", "teal"];

function changeColor()
{

const color = colors[parseInt(Math.random()*3)];
document.getElementById('sak').innerHTML = color;
document.body.style.background = color
document.getElementById('bak').style.background = color;




}



</script>

<style>
.A{
display: flex;
position: relative;
justify-content: center;
}
button{

height: 50px;
width: 100px;
background-color: pink;
margin-top: 50px;
}

#sak {
text-align: center;
}
</style>

</head>
<body>
<div class="A">
<button id="bak" onclick="changeColor()">Click Me! </button>

</div>
<h1 id="sak"></h1>

</body>
</html>

0 comments on commit 885fd57

Please sign in to comment.