Guest User

Untitled

a guest
May 20th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <div id="root">
  2. <div class="header"></div>
  3. <div class="body">
  4. <div class="text-left" id="text-one">
  5. <p>Some text taking up multiple lines</p>
  6. </div>
  7. <div class="text-right" id="text-two">
  8. <p>Other text</p>
  9. </div>
  10. </div>
  11. </div>
  12.  
  13. <html><head><title>test</title></head><body>
  14.  
  15. <div id="root" style="border:1px solid red">
  16. <div class="header"></div>
  17. <div class="body">
  18. <div class="text-left" id="text-one" style="float: left;">
  19. <p>Some text taking up multiple lines</p>
  20. </div>
  21. <div class="text-right" id="text-two" style="float: right;">
  22. <p>Other text</p>
  23. </div>
  24. </div>
  25. </div></body>
  26.  
  27. var height = Math.max(leftHeight, rightHeight);
  28.  
  29. var max_height = 0;
  30. $.each( $('#root div'), function(x, y){
  31. var yHeight = $(y).height();
  32. max_height = ( yHeight > max_height) ? yHeight : max_height;
  33. });
  34. console.log(max_height); //should have the height value.
  35.  
  36. $('#root .body').addClass('clearfix');
  37.  
  38. $('#root').height();
  39.  
  40. <div id="root">
  41. <div class="header"></div>
  42. <div class="body">
  43. <div class="text-left" id="text-one">
  44. <p>Some text taking up multiple lines</p>
  45. </div>
  46. <div class="text-right" id="text-two">
  47. <p>Other text</p>
  48. </div>
  49. </div>
  50. <div style="clear: both;"></div>
  51. </div>
  52.  
  53. #root {
  54. background-color: lightgreen; /* for demo purposes */
  55. overflow: hidden;
  56. }
  57.  
  58. $('#root').css( 'overflow', 'hidden' );
  59. // ...then your height code
Add Comment
Please, Sign In to add comment