The opacity property is set to css:
#something { opacity: .5; }
HTML:
<body id="something">
How do i get the value of this property in javasciprt? We need an exact answer from someone who knows for sure.
How do i get ...">
The opacity property is set to css:
#something { opacity: .5; }
HTML:
<body id="something">
How do i get the value of this property in javasciprt? We need an exact answer from someone who knows for sure.
function getStyle(el,styleProp) { var x = document.getElementById(el); if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y; } alert(getStyle("something", "opacity"));
Let's replace the word f ** k with di
document.getElementById('di').style.opacity
$("#something").css("opacity");
If you are interested in looking at the most complete code snippet, then like this:
<script type="text/javascript" src="http://yandex.st/jquery/1.6.2/jquery.min.js"> </script> <script> $(document).ready(function() { alert("opacity: " + $("#something").css("opacity")); }); </script> <style> #something { opacity: 0.45; } </style> <body id="something"> </body>
$(document.body).css("opacity");
The jQuery library is used.
Try to use markup and do not use informal language.
How to use markup here .
Source: https://ru.stackoverflow.com/questions/21427/
All Articles