
jQuery is a beautiful javascript library that simply makes things easier. I recently ran into a case where a client wanted several boxes with variable content to be as long as the longest box. Of course, jQuery came to the rescue…
Say you have a box (div) displaying a different testimonial every time the page is loaded. And you want two other boxes to be the same height as the one with the variable size testimonial.

* Note that if your content contains images, you will want to run the script once the window is loaded instead.
Nice & easy:
1 2 3 4 5 6 7 8 | var maxHeight = 0; $('.box').each(function() { var boxHeight = $(this).height(); if(boxHeight > maxHeight) maxHeight = boxHeight; }); $('.box').css({ height : (maxHeight + 'px') }); |
I will actually work on a example integrating WordPress into the equation and update this article as soon as I get some spare time in my hands.
If you have a more efficient method, please comment away! Otherwise, I hope you find this useful.
Listen to what others have to say about their experience working with me.
Which of the following do you think will have a greater impact on your final decision of hiring a particular web designer?
Learn a little about how I do what I love, what makes me unique and my work ethics.