get div height after div content load

℡╲_俬逩灬. 提交于 2020-01-03 09:02:41

问题


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.

This is my code:

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

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

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


回答1:


You can get it from element clientHeight :

document.getElementById("test").clientHeight



回答2:


I dont want to search through the source on your site so here is a crack at what I think you are talking about.

<div id="firstdiv"></div>
<div id="seconddiv"></div>

<script>
    $("firstdiv").change(function () {
        var s= $("seconddiv").height();
        $(this).height(sndHeight);
    });
</script>



回答3:


Here is your answer:

$( document ).ready(function() {
  $("#firstDiv").css('height',$("#secondDiv").height());
});

And a demo you find here : http://fiddle.jshell.net/stryd3r/MgnT8/



来源:https://stackoverflow.com/questions/20358943/get-div-height-after-div-content-load

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!