あり、単純なHTMLとJavaScriptのコードです:element.style表示誤った情報
<html>
<head>
<style>p { height: 100px;} </style>
<script>
window.onload = function(){
var p = document.getElementsByTagName("p")[0];
alert("actual height is " + p.style.height);
};
</script>
<title>JavaScript Tests</title>
</head>
<body>
<p>
100px height p element
</p>
</body>
</html>
は、しかし、我々はそれを実行したときに実際の高さは、空の文字列に等しいです。
理由を説明してください。
ありがとうございます。
「getComputedStyle()」は、一般的なバージョンのIEではうまくサポートされていません。 – cdhowie
確かに。 IEでは代わりに 'elem.currentStyle.height'を使うことができます。 –