JavaScript Tutorial/Style/currentStyle — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:24, 26 мая 2010
element.currentStyle.backgroundColor
<source lang="javascript">
This example uses a custom Internet Explorer property and will not work in other browsers. <html>
<head> <title>Computed Style Example</title> <style type="text/css"> div.special { background-color: inherit; } </style> <script type="text/javascript"> function getBackgroundColor() { var oDiv = document.getElementById("div1"); alert(oDiv.currentStyle.backgroundColor); } </script> </head> <body>
<input type="button" value="Get Background Color" onclick="getBackgroundColor()" /> </body>
</html></source>
element.currentStyle.height
<source lang="javascript">
This example uses a custom Internet Explorer property and will not work in other browsers. <html>
<head> <title>Computed Style Example</title> <style type="text/css"> div.special { background-color: red; height: 10px; } </style> <script type="text/javascript"> function getBackgroundColor() { var oDiv = document.getElementById("div1"); alert(oDiv.currentStyle.height); } </script> </head> <body>
<input type="button" value="Get Background Color" onclick="getBackgroundColor()" /> </body>
</html></source>
element.currentStyle.margin
<source lang="javascript">
This example uses a custom Internet Explorer property and will not work in other browsers. <html>
<head> <title>Computed Style Example</title> <style type="text/css"> div.special { background-color: red; margin: 10px; } </style> <script type="text/javascript"> function getBackgroundColor() { var oDiv = document.getElementById("div1"); alert(oDiv.currentStyle.margin); } </script> </head> <body>
<input type="button" value="Get Background Color" onclick="getBackgroundColor()" /> </body>
</html></source>