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?

2

3 Answers 3

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>
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/

3
  • take a look here then: stackoverflow.com/questions/172821/…
    – Aditzu
    Commented Dec 3, 2013 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. Commented Dec 3, 2013 at 20:16
  • just put these code, and in <SCRIPT type=text/javascript> ...</SCRIPT> and add the id 'firstDiv' and 'secondDiv' for both divs that you want it equal , and of course load jquery library.
    – Aditzu
    Commented Jan 30, 2014 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.