助けが必要です。3 つのボタンを作成しました。そのうちの 1 つをクリックすると、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';
}
}
ボタンをもう一度クリックしても、古いスタイルに戻りません。なぜなのかご存知ですか?