2

Live: http://rafflebananza.com/Admin/Desktop/index123.html#

I am trying to use JQuery to obtain the height for the amount of administrators under the users section of the quick side bar you see to the right.

    var temp = $('.Admins').height();
    alert(temp);

The above what should be working script, regardless of if I enclose within document ready or window load, always returns the value of 0 and not the height.

  • 2
    The div IS 0 in height as far as I can see with the inspector tool.. – display-name-is-missing Apr 17 '16 at 23:04
  • 2
    Before the closing tag of the .Admins div, put this code in `
    `, right now, because of the float of the elements inside, the parent container height is 0
    – display-name-is-missing Apr 17 '16 at 23:05
  • Related: [floating stuff within a div, floats outside of div. Why?](http://stackoverflow.com/questions/2062258/floating-stuff-within-a-div-floats-outside-of-div-why) Also [Which method of ‘clearfix’ is best?](http://stackoverflow.com/questions/218760/how-do-you-keep-parents-of-floated-elements-from-collapsing) – Jonathan Lonowski Apr 17 '16 at 23:08
  • @DanielLisik this works perfectly. Can you submit this as an answer explaining? –  Apr 17 '16 at 23:10

2 Answers2

2

It's because of the float style in the child elements. Try adding this code to clear the float:

.Group.Admins::after {
    content: '';
    clear: both;
    display: block;
}
display-name-is-missing
  • 4,424
  • 5
  • 28
  • 41
  • [David Horák Anser](http://stackoverflow.com/a/36683216/2199267) works perfectly too, don't know why this is the reason but thank you both! –  Apr 17 '16 at 23:16
0

The div Group Admins doesn't have height. Try to add float: left; to Group Admins and you will get the height.

David Horák
  • 5,535
  • 10
  • 53
  • 77