2012-07-06 21 views

Respuesta

8

establecer un valor en una hoja de estilo CSS no es lo mismo que establecer a través de la propiedad style. Necesitará mirar el método getComputedStyle para obtener esto (y también currentStyle para IE más antiguo).

+0

Para IE se necesita una solución, ya que no tiene getComputedStyle, ejemplo: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml – TheZ

+1

gracias, yo no sabía nada de – John

-1
document.getElementById("em").style.opacity; 

funcionará bien si utiliza el estilo en línea .eg.

<div id="em" style="width: 50px; height: 50px; opacity: 0.5;"> 
+0

su opacidad * BTW – Xeieshan

+0

OOPS ............ – mohsin

3
var em = document.getElementById("em"); 
var temp = window.getComputedStyle(em).getPropertyValue("opacity"); 

Ahora, la variable temp tendrá el valor de opacidad de "em".

Cuestiones relacionadas