html - Can't Access CSS Selector's Properties from Javascript -
This is a very basic question: how to terminate the code in the below code () function to reach the 'opacity' property Not #myStyle for CSS selector? The warning does not display anything, and I have verified that the 'ambiguity' property is 'false'.
Thanks a lot!
& lt; Html & gt; & Lt; Top & gt; & Lt; Style type = "text / css" & gt; & Lt ;! - #myStyle {Opacity: 0.50; } - & gt; & Lt; / Style & gt; & Lt; Script type = "text / javascript" & gt; & Lt ;! - Function expired () {Warning (document.getElementById ('myStyle'). Style.opacity); } - & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body Onload = "Endloading ();" & Gt; & Lt; Div id = "myStyle" & gt; Hello & lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
You can get the prescribed values only through the class after their calculation.
var oElm = document.getElementById ("myStyle"); Var strValue = ""; If (document.defaultView & amp; document.defaultView.getComputedStyle) {strValue = document.defaultView.getComputedStyle (OLAM, blank) .getPropertyValue ("- Mojo-opacity"); } Else if (oElm.currentStyle) // IE {strValue = oElm.currentStyle ["Opacity"]; } Alert (strValue);
Comments
Post a Comment