[英]I want to change the color of the first Button, when I clicked on the second
我对编码很陌生。 我找到了灵感并开始制作我的网站。 我做了一个标志和 2 个按钮,镜头和设计师。 当我单击第一个和第二个按钮时,它们都将颜色更改为白色,但这不是我想要的。 我希望当我单击第二个按钮时,第一个按钮将此颜色更改为开始颜色(灰色)。我的意思是如果单击按钮 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>```
这是找你的零钱
<script> function myButton() { document.getElementById("demo").style.color = "white"; } function mysecondButton() { document.getElementById("demo").style.color = "grey"; } </script>
function myButton() {
document.getElementById("demo").style.color = "white";
}
function mysecondButton() {
document.getElementById("demo").style.color = "grey";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.