I have a page where I want the div standing next to each other to be of equal height.
I have the following function:
function setProjectsHeight() { var count = 0; $(".project").each(function() { if(count % 3 === 0) { var highest = 0; for(i=count;i<=count+2;i++) { if($("div.project#"+i).height() > highest) { highest = $("div.project#"+i).height(); } } console.log(highest); } count++; }); }
Somehow, the height is always zero. The selector seems to be right (checked), and when console.log () is the width with the same selector, it returns 200 (correctly).
EDIT: Just decided! Somehow I had the idea to set "body {display: none}" in css and set this property back to "block" at the end of document.ready (). I did this because I am using jQuery UI buttons, and users have seen that these buttons switch from a regular UI bar link.
When I removed this functionality, everything worked again. It seems when setProjectsHeight () was called, the body was still showing: block. Thus, there was no calculated height.
Thanks for your help!
source share