ID を持つ div がありopacity:0.75;
、これは 0.75 の不透明度で画面に div を表示します。js で不透明度を変更したい場合は機能しません。アラートを使用して style.opacity の値を確認しましたが、アラートが空白になります。代わりにstyle.opacity = "0.75";
js コードに ... がある場合は機能します (画面上では、オブジェクトは本来のように 75% 不透明に見え、アラートは 0.75 で表示されます)。どうしてこれなの?
label.style.opacity = parseFloat(label.style.opacity, 10) - 0.1; alert(label.style.opacity);
とcss
#label {
width:100px;
text-align:center;
height:50px;
font-size:normal;
position:absolute;
color:white;
z-index:100;
font-family:Helvetica-Light;
}