How to get height of the highest children element in javascript/jQuery?

后端 未结 4 631
無奈伤痛
無奈伤痛 2020-12-05 05:10

I need a function to get the height of the highest element inside a div.

I have an element with many others inside (dynamically generated), and when I ask for the he

4条回答
  •  死守一世寂寞
    2020-12-05 05:49

    You could always do:

    var t=0; // the height of the highest element (after the function runs)
    var t_elem;  // the highest element (after the function runs)
    $("*",elem).each(function () {
        $this = $(this);
        if ( $this.outerHeight() > t ) {
            t_elem=this;
            t=$this.outerHeight();
        }
    });
    

    Edited to make it work again.

提交回复
热议问题