Find out divs height and setting div height

后端 未结 9 937
天涯浪人
天涯浪人 2020-12-14 21:41

I\'m quite new to javascript/jquery stuff, but i would like to do this kind of thing with it:

I have four divs side-by-side like this and content in each one. Now if

9条回答
  •  眼角桃花
    2020-12-14 21:57

    I was getting a NaN error with SLaks code. Giving maxHeight an initial value of 0 did the trick.

    var maxHeight = 0;
    $('div')
      .each(function() { maxHeight = Math.max(maxHeight, $(this).height()); })
      .height(maxHeight);
    

    Thanks SLaks!

提交回复
热议问题