我需要一些帮助:我制作了三个按钮,单击其中一个按钮后,应通过 Javascript 更改其样式。那是有效的。但是应该会发生其他事情:一旦我再次单击按钮,应该恢复旧样式。看一下代码:
function changeStyleOne(){
if(this.style.background != 'rgba(207,207,207,.8)'){
this.style.background = 'rgba(207,207,207,.8)';
this.style.boxShadow = '0 5px 20px rgba(0,0,0,.3) inset';
this.style.borderLeft = '0';
this.style.width = '99px';
button2.style.background = '-webkit-linear-gradient(bottom, #B9B9B9 0%, white 90%)';
button2.style.width = '98px';
button2.style.borderLeft = '1px solid white';
button2.style.boxShadow = '';
button3.style.background = '-webkit-linear-gradient(bottom, #B9B9B9 0%, white 90%)';
button3.style.width = '98px';
button3.style.borderLeft = '1px solid white';
button3.style.boxShadow = '';
displayContent1();
}else{
this.style.background = '-webkit-linear-gradient(bottom, #B9B9B9 0%, white 90%)';
this.style.boxShadow = '';
this.style.borderLeft = '1px solid white';
this.style.width = '98px';
}
}
那不起作用:当我再次单击该按钮时,它不会恢复旧样式。你知道为什么吗?