Reputation: 3
I am very new to coding. I found a inspiration and started making my website. I made a logo and 2 buttons, Shots and Designers. When I click on the first and the second button, they both change their color to white, but thats not what I want. I want that when I click on the second button, the first button change this color to start color (grey).I mean if button 2 clicked, change button 1 color to grey. Here is my code:
<head>
<title>Richis corner</title>
</head>
<head>
<style>
.rectangle {
height: 85px;
width: 4500px;
background-color: #242526;
margin-top: -43px;
margin-left: -8px;
}
.image {
margin-top: -147px;
margin-left: -50px;
}
.button1 {
font-family: Helvetica;
background: none;
color: grey;
border: none;
font-size: 18px;
outline: none;
}
</style>
</head>
<body>
<div class="rectangle"></div>
<img src=https://i.yapx.ru/Koe4kb.png" class="image">
<button style="margin:-37px -25px;position: absolute;" class="button1" id="demo" onclick="myButton()">
Shots</button>
<button style="margin:-37px 50px;position: absolute;" class="button1" id="demo2"
onclick="mysecondButton()"> Designers</button>
<script>
function myButton() {
document.getElementById("demo").style.color = "white";
}
function mysecondButton() {
document.getElementById("demo2").style.color = "white";
}
</script>
</body>```
Upvotes: 0
Views: 484
Reputation: 236
Here is your change
<script>
function myButton() {
document.getElementById("demo").style.color = "white";
}
function mysecondButton() {
document.getElementById("demo").style.color = "grey";
}
</script>
Upvotes: 1
Reputation: 101
function myButton() {
document.getElementById("demo").style.color = "white";
}
function mysecondButton() {
document.getElementById("demo").style.color = "grey";
}
Upvotes: 0