asp.net jquery元素 - 获取项目的总高度

asp.net jquery元素 - 获取项目的总高度

问题描述:

嗨专家,



我有一个jquery元素,预设高度为200px,溢出隐藏和位置相对;无法改变的。我想得到实际元素的高度,因为它里面的项目的高度和数量不同。也就是说,没有一个元素正好是200px,因为如果一个元素有2个项目则非常短,而如果另一个元素有20个项目它会相对更高。一种方法是遍历元素中的项目,+ =它们的高度对吗?



a)。有没有一个有效的jquery循环来做到这一点? (每个......)

b)。你知道有什么其他方法可以获得屏幕上出现的元素的真实高度吗?



如果你不明白我的问题,请告诉我,我会找到更好的方法。



非常感谢你的帮助,

贾斯汀

Hi Experts,

I have a jquery element with a preset height 200px, overflow hidden and position relative; that cannot be changed. I would like to get the height of the actual element since the items inside it differ in height and quantity. That is, no one element is exactly 200px because if one has 2 items it is very short and if the other has 20 items it would be relatively much taller. One way to do this is to traverse the items in the element and += their height right?

a). Is there an efficient jquery loop to do this? (for each...)
b). Do you know of any other way of getting the REAL height of the element as it appears on screen?

If you do not understand my question, kindly let me know and I will find a better way.

Thanks a lot for your assistance,
Justin

如果你需要知道没有它的高度会是多少隐藏,请参阅scrollHeight属性(即使没有隐藏溢出的滚动条):



If you need to know what the height would have been without some of it being hidden, refer to the scrollHeight property (even though there''s no scrollbar with overflow hidden):


(''#whatever'')[0] .scrollHeight
(''#whatever'')[0].scrollHeight


使用此功能查找最大高度:



功能(){



var max = 0;



this.each(function(){

max = Math.max(max,
Use this function to find the max height:

function() {

var max = 0;

this.each(function() {
max = Math.max( max,