【发布时间】:2016-03-19 08:19:37
【问题描述】:
如何在调整大小事件后知道元素的高度?我使用 jQuery 的函数 .height() 并且在使用我的调整大小函数之前我有一个 500 毫秒的计时器,但是函数 .height() 仍然返回调整大小之前的高度。
$(window).resize(function() {
window.clearTimeout(timerResize);
timerResize = setTimeout(recalculateAll, 1000);
});
function recalculateAll() {
console.log('resize');
setOpenClose('.auteurs .block');
}
function setOpenClose(target) {
$(target).each(function() {
$(this).data('height', $(this).height());
$(this).height($(this).height() - ($(this).find('p').height() + 45));
});
sameHeights(target);
}
function sameHeights(target, locus) {
if (locus === undefined) {
locus = target;
}
var heightMax = 1;
$(target).each(function() {
if ($(this).height() > heightMax) {
heightMax = $(this).height();
}
});
$(target).each(function() {
$(this).height(heightMax);
});
}
希望我的问题是可以理解的,因为我的英语很接近,而且我是开发新手。
【问题讨论】:
标签: javascript jquery resize height