Javascript 当我点击第二个按钮时,我想改变第一个按钮的颜色

Javascript 当我点击第二个按钮时,我想改变第一个按钮的颜色,javascript,html,css,Javascript,Html,Css,我对编码很陌生。我找到了灵感,开始制作我的网站。我做了一个标志和两个按钮,照片和设计师。当我单击第一个和第二个按钮时,它们都将颜色更改为白色,但这不是我想要的。我希望当我点击第二个按钮时,第一个按钮将此颜色更改为开始颜色(灰色)。我的意思是,如果点击按钮2,将按钮1的颜色更改为灰色。 这是我的密码: <head> <title>Richis corner</title> </head> <head> <style>

我对编码很陌生。我找到了灵感,开始制作我的网站。我做了一个标志和两个按钮,照片和设计师。当我单击第一个和第二个按钮时,它们都将颜色更改为白色,但这不是我想要的。我希望当我点击第二个按钮时,第一个按钮将此颜色更改为开始颜色(灰色)。我的意思是,如果点击按钮2,将按钮1的颜色更改为灰色。 这是我的密码:

 <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>```




里奇斯角
.矩形{
高度:85px;
宽度:4500px;
背景色:#242526;
利润上限:-43px;
左边距:-8px;
}
.形象{
边缘顶部:-147px;
左边距:-50px;
}
.按钮1{
字体系列:Helvetica;
背景:无;
颜色:灰色;
边界:无;
字号:18px;
大纲:无;
}
镜头
设计师
函数myButton(){
document.getElementById(“演示”).style.color=“白色”;
}
函数mysecondButton(){
document.getElementById(“demo2”).style.color=“白色”;
}
```
这是找您的零钱


函数myButton(){
document.getElementById(“演示”).style.color=“白色”;
}
函数mysecondButton(){
document.getElementById(“演示”).style.color=“灰色”;
}

您可以使用
.style.color=“”)将其更改回默认值(或者更确切地说,无论CSS定义了什么)。你应该可以从那里找到答案。我希望这样:如果点击按钮2,将按钮1的颜色更改为灰色,但我如何将其作为代码编写?与将按钮2设置为白色的方式完全相同,但按钮1和灰色。因此,你知道如何将按钮颜色设置为白色,但不知道如何将其设置为灰色?怎么回事!不,我解释得不对。如果按钮2点击,将按钮1的颜色更改为灰色。不,不是那样,我的意思是,如果按钮2点击,将按钮1的颜色更改为灰色,我将其更改。请现在尝试我的代码。我如何将其写成“如果单击按钮2,将按钮1颜色更改为灰色”?现在尝试我的代码
function myButton() {
  document.getElementById("demo").style.color = "white";
}
function mysecondButton() {
  document.getElementById("demo").style.color = "grey";
}