我正在使用javascript來顯示當前div的高度。Javascript樣式問題
這是影響區域
//css
.test
{
height:1px;
}
#test1
{
margin:1px;
}
//html
<div id="test1" class="test"></div>
//javascript
var a = document.getElementById('test1');
a.style.height //how I access the style
螢火蟲說的風格的長度爲0和高度爲空的一個例子。 我如何獲得正確的身高?
謝謝,問題已解決。我使用了a.style.offsetHeight,而不是僅使用a.offsetHeight – Drake