javascript - ie7 获取clientHeight&clientWidth总是0
ringa_lee
ringa_lee 2017-04-10 14:52:13
0
2
368
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    .content{}
    .item{height:20px;border:1px solid #ddd;}
    </style>
</head>
<body>

<p id="content" class="content">
    <p id="item" class="item">aaa</p>
</p>

<script type="text/javascript">
    var item = document.getElementById('item'), ch = item.clientHeight, pch = item.parentNode.clientHeight;
    console.log({ch: ch, pch: pch});
</script>
</body>
</html>

IE7下能获取.item的clientHeight但获取不到.content的clientHeight

chrome下是正常的

ringa_lee
ringa_lee

ringa_lee

人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!