在div内容加载后得到div高度 [英] get div height after div content load

查看:222
本文介绍了在div内容加载后得到div高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个 div 的高度设置为等于另一个。我会称他们为左右div。正确的 div 内容并不总是相同,并且加载了jQuery。它是一个过滤器,所以每次单击过滤器,内容更改以及父div高度。

I am trying to set the height of one div equal to another. I will call them left and right divs. The right div content is not always the same and is loaded with jQuery. It is a filter so each time you click a filter, the content change and also the parent div height.

这是我的代码:

jQuery(document).ready(function($) {
    $(window).resize(function() {
        location.reload();
    });
    var Height = $("#archive").outerHeight();
    $('.recursos-sidebar').css("height", Height);
});

问题是当div为空时,左div高度等于右div(没有内容是加载)。

The problem is that the left div height is equal to right div when it is empty (no content is loaded).

有人知道每次内容更改后如何获得正确div的高度?

Somebody know how can I get the height of the right div after the content change each time?

推荐答案

你可以从元素clientHeight获取它:

You can get it from element clientHeight :

document.getElementById("test").clientHeight

这篇关于在div内容加载后得到div高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆