简单的jQuery获取隐藏元素高度、jQuery获取元素高度、jQuery获取DIV高度

 jQuery获取隐藏元素高度,了解一下

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>简单的jQuery获取隐藏元素高度、jQuery获取元素高度、jQuery获取DIV高度</title>
	<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
	<style type="text/css">
		html,body{margin: 0;padding: 0;}
		.ShowHide{display: none;}
		.ShowHideCh{display: none;}
	</style>
	<script type="text/javascript">
		jQuery(function () {
			jQuery('.ShowHide').css({'visibility': 'hidden','overflow': 'hidden','display': 'block','position': 'absolute','top': '-10000px'});//先占位置
			var GetHeight = jQuery('.ShowHide').height();
			var GetHeightCh = jQuery('.ShowHideCh').height();
			//alert(GetHeight);
			//alert(GetHeightCh);
			jQuery('.ShowHide').css({'visibility': '','overflow': '','display': '','position': '','top': ''});//去掉占位置
		});
	</script>
</head>
<body>
<div class="ShowHide">
	<div class="ShowHideCh">
		<p>666666</p>
		<p>666666</p>
		<p>666666</p>
		<p>666666</p>
	</div>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
	<p>666666</p>
</div>
<p>666666</p>
</body>
</html>

 大家有好的方式欢迎一起探讨!

猜你喜欢

转载自blog.csdn.net/weixin_42350070/article/details/82908400