How to make a button that switches between two colours?
This JavaScript will only change the colour one way. How could I make it so only the one button can be dark/selected at a time depending which button you select?
this is for a small log-in window on my site, and I'm trying to make it switch between two tabs/menus. Any help would be appreciated!
var login = document.querySelector('#login');
var signup = document.querySelector('#signup');
login.onclick = function() {
if (login.style.backgroundColor === "#a8661f") {
login.style.backgroundColor = "#d18029";
} else {
login.style.backgroundColor = "#a8661f"
}
signup.onclick = function() {
signup.style.backgroundColor = "#a8661f";
}
}
#log_in_box {
margin-top: 100px;
text-decoration: none;
margin-bottom: 100px;
font-size: 20px;
font-weight: bold;
}
#log_in_box button {
margin-top: 30px;
display: inline-block;
font-weight: bold;
font-size: 20px;
right: 5px;
position: relative;
bottom: 85px;
color: white;
border: 5px solid #a8661f;
border-radius: 20px 20px 0 0;
padding: 10px;
}
#login {
background-color: #d18029;
}
#signup {
background-color: #d18029;
}
Username:
enter your username
Password:
enter your password