2

I'm using this JQuery function to equal my div heights:

//equalize funciton function equalHeight(group) { tallest = 0; group.each(function() { thisHeight = $(this).height(); if(thisHeight > tallest) { tallest = thisHeight; } }); group.height(tallest); } 

With this OnLoad:

$(window).load(function(){ equalHeight($("#div_right, #div_left, #div_bottom, .border")); }); 

It requires that I refresh the page in order for it to take affect (after the page is resized). I would like it to either do it as the user is dragging the window, or just refresh the page after.

Which is recommended? I know the page resize won't be very smooth if the JQuery function is consistently reloading. Also, how could I change my code to fit either option?

1 Answer 1

1

Call your function on both $(window).resize() and $(document).ready(). It will be OK.

EDITION:
I think this is what you need:

<script type="text/javascript"> $(window).resize(function() { equalHeight($("#div_right, #div_left, #div_bottom, .border")); }); $(document).ready(function() { equalHeight($("#div_right, #div_left, #div_bottom, .border")); }); </script> 
Sign up to request clarification or add additional context in comments.

4 Comments

Hmm i'm running all three now, but it no longer resizes the divs at all. ' <script type="text/javascript"> $(window).load(function(){ $("#div_right, #div_left, #div_bottom, .border"); }); </script> <script type="text/javascript"> $(window).resize(function() { $("#div_right, #div_left, #div_bottom, .border"); }); </script> <script type="text/javascript"> $(document).ready(function() { $("#div_right, #div_left, #div_bottom, .border"); }); </script>
$("#div_right, #div_left, #div_bottom, .border"); is not correct. call this one equalHeight(group) with an appropriate argument.
That equals the heights, but the page still needs a refresh, like previously.
I'm not sure if I can adapt this function, going to look and see what others have created to solve this issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.