你是想用css实现,还是js。还有你代码写的不对最后一个<body>,应该是</body><buttontype="submit",id="d1"class="buttonitem1"οnclick="document.getElementById('d1').style.background='#ffa200';document.getElementById('d2').style.background='#0a56bb';document.getElementById('d3').style.background='#0a56bb';">第一个按钮</button><buttontype="submit",id="d2"class="buttonitem2"οnclick="document.getElementById('d2').style.background='#ffa200';document.getElementById('d1').style.background='#0a56bb';document.getElementById('d3').style.background='#0a56bb';">第二个按钮</button><buttontype="submit",id="d3"class="buttonitem3"οnclick="document.getElementById('d3').style.background='#ffa200';document.getElementById('d2').style.background='#0a56bb';document.getElementById('d1').style.background='#0a56bb';">第三个按钮</button>设置一个id,onclick是点击事件,点击后变色,其他回复原来颜色,每个点击事件有三个document,第一个是变色,后两个是恢复,如果不要他恢复就删掉。这只是简单js写法,适合初学但不实用,可以自己先研究一下,不明白的地方可以再问我
阅读全文 >