怎样获取一个display:none的元素的宽高?
补充问题【按照以下代码测试】
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<style type="text/css">
.m1 {
display: none;
width: 500px;
height: 500px;
margin: 0px auto;
border: 1px solid red;
}
.m2 {
width: 50%;
height: 5%;
border: 1px solid red;
}
</style>
<!-- 这里可以自行引用jQuery -->
<script type="text/javascript" src="js/jquery-1.8.3/jquery.min.js"></script>
</head>
<body>
<div id="m1" class="m1">
<div id="m2" class="m2"></div>
</div>
<script type="text/javascript">
console.log($('#m2').height());
</script>
</body>
</html>
有只小跳蛙
相关分类