amit amit - 1 month ago 12
Javascript Question

Jquery function to find out max height of <li>

I want to find out that out of the given

<li>
which
li
has the maximum height?
how do i write such function?

If there are n
<li>
elements of different size, content and height. I want to figure out the maximum height of the biggest
<li>
element.

Answer

Try this:

var max = -1;
$("li").each(function() {
    var h = $(this).height(); 
    max = h > max ? h : max;
});
alert(max);
Comments