【发布时间】:2018-06-14 19:41:23
【问题描述】:
我需要帮助让多个按钮在单击时更改颜色,并在第二次单击时返回以前的颜色。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<style>
.choices{
background-color:#F0F3F4;
padding:15px 32px;
display:inline-block;
font-size:16px;
font-family:century gothic;
font-weight:bold;
margin:6px 4px;
cursor:pointer;
border-radius:12px;
border:2px solid #5D6D7E;
}
.choices:hover{
background:#D0D3D4;
}
</style>
<script>
</script>
</head>
<body>
<div>
<button class="choices" type="button" id="button" >Grapes</button>
<button class="choices" type="button" id="button">Bananas</button>
<button class="choices" type="button" id="button">Strawberries</button>
<button class="choices" type="button" id="button">Apples</button>
</body>
</html>
我对 javascript 不是超级有经验,所以我想我只需要帮助弄清楚如何使用 javascript 来解决问题。
【问题讨论】:
标签: javascript html css button colors