Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:06:58+00:00 2026-06-14T03:06:58+00:00

In a previous question , I set Equal heights on individual <li> tags from

  • 0

In a previous question, I set Equal heights on individual <li> tags from UL groups on a page. But now I realize for better theming, I’d like to take the tallest height set on a group of <li> tags within a UL group and set that to its respective parent <ul> itself specifically for better theming of my page. I have a new fiddle here where I try to find the tallest height of an <li> within a UL group and set it to the UL.

The issue still is specificity. The tallest height of the the <li> from the first UL group is being set to all <ul> tags on the page. The height of the tallest <li> in UL group (row 1) is 260px and the height from Row 2 is 156px. However, 260px is still being set to both UL tags on the page. The ULs will grow upon the page so I’d like the code to be extensible without having to specify each row in JQuery. So far I have tried this:

// get the height of the tallest LI within each UL group
    var max = Math.max.apply(Math, $(".item-list ul li").map(
        function(){
          return $(this).height();
        }
      ));

// now render the height in each parent UL

    $(".item-list ul").each(function() {
      $(this).find(".item-list ul").height(max);
    });

… but the second part does not work. This works but…

$(".item-list ul").height(max);

… it puts the height of the tallest <li> on the pages for all UL tags. Ideally the final HTML should be:

<div class="item-list row-1">
<ul style="height: 260px;">
etc...

<div class="item-list row-2">
<ul style="height: 156px;">
etc...

Working version based on this one below

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:06:59+00:00Added an answer on June 14, 2026 at 3:06 am

    If I understand you correctly, you should do the max operation in the .each() loop.

    function thisHeight(){
        return $(this).height();
    }
    
    $(".item-list ul").each(function() {
        var thisULMax = Math.max.apply(Math, $(this).find("li").map(thisHeight));
        $(this).height(thisULMax);
    });
    

    I also made the map function a named function so you can reuse it.


    Here are a couple more solutions that are a little cleaner.

    This one passes a function to height() to use it as the iterator. Shortens things a bit.

    function thisHeight(){
        return $(this).height();
    }
    
    $(".item-list ul").height(function() {
        return Math.max.apply(Math, $(this).find("li").map(thisHeight));
    });
    

    Here’s another way using .reduce(), though it needs a shim for IE8 and lower.

    function maxHeight(max, elem) {
        var h = $(this).height();
        return max > h ? max : h;
    }
    
    $(".item-list ul").height(function() {
        return $(this).find("li").toArray().reduce(maxHeight, 0);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After running code from my previous question , I get a result set from
This is a continuation question from a previous question I have asked I now
This question follows on from a previous question, that has raised a further issue.
This question ties to my previous question but is more specific. Say I have
I have below a function (from a previous question that went unanswered) that creates
From the previous question I asked, I am still having the same question. I
I have javascript to set equal column heights of two divs contained by a
This question is based off of this previous question of mine: Android - Set
In reference to my Previous Question someone said in select query if I set
(look also at my previous question ) I'm trying to repeat set of curlopt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.