9

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?

ThemesCreator
  • 1,749
  • 6
  • 27
  • 49

3 Answers3

2

You can get it from element clientHeight :

document.getElementById("test").clientHeight
0

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>
Zach Spencer
  • 1,859
  • 15
  • 21
0

Here is your answer:

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

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

Aditzu
  • 696
  • 1
  • 14
  • 25
  • take a look here then: http://stackoverflow.com/questions/172821/detecting-when-a-divs-height-changes-using-jquery – Aditzu Dec 03 '13 at 19:02
  • i have been reading it but my knowledge on javascript and jquery are poor and dont now what and how to implement these codes. – ThemesCreator Dec 03 '13 at 20:16
  • just put these code, and in and add the id 'firstDiv' and 'secondDiv' for both divs that you want it equal , and of course load jquery library. – Aditzu Jan 30 '14 at 16:09