如何获取< div>的高度在px维度 [英] How to get height of <div> in px dimension
本文介绍了如何获取< div>的高度在px维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery库来找出 div
的高度。
I have used jQuery library to find out height of a div
.
下面是我的 div
具有属性的元素:
Below is my div
element with attributes :
<DIV id="myDiv" style="height:auto; width:78;overflow:hidden"> Simple Test</DIV>
下面是我的jQuery代码获取< div& code>
Below is my jQuery code to get height of <div>
var result = $("#myDiv").css('height');
alert(result);
执行上述语句后,我得到的结果为auto。
After executing above statement I am getting result as "auto". Actually this is I am not expecting, instead of that I want the result in px dimension.
推荐答案
使用 .height()
如下:
var result = $("#myDiv").height();
还有 .innerHeight()
和 .outerHeight )
。
您可以在此处测试,使用padding / margin / content查看其变化。
You can test it here, play with the padding/margins/content to see how it changes around.
这篇关于如何获取< div>的高度在px维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文