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

  • SEARCH
  • Home
  • 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 8956687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:50:29+00:00 2026-06-15T14:50:29+00:00

It sounds like such a easy task but I am finding this very hard

  • 0

It sounds like such a easy task but I am finding this very hard to get this working correctly due to images loading after the script and hidden children. I keep getting different heights each time I load the page.

http://jsfiddle.net/ek5Uf/

$("h2").click(function(){
    var $wrap = $(this).parents(".wrapper");
    $wrap.find(".scroller").height(function(){
        var height = 0;            
        $wrap.find(".scroller > li:lt(3)").each(function(){
            height += $(this).outerHeight(true);
        });
        return height;
    }).slideDown();
});

$("h2").eq(0).click();
  • 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-15T14:50:29+00:00Added an answer on June 15, 2026 at 2:50 pm

    Not very elegant, but this should be a sturdy solution for setting the scroller’s height to the height of its first 3 li items:

    $("h2").click(function(){
        var $wrap = $(this).closest(".wrapper");
        $wrap.find(".scroller").height(function() {
            var lis = $("> li:gt(2)", this).detach(),
                ret = $(this).outerHeight(true);
            $(this).append(lis);
            return ret;
        }).slideDown();
    });
    

    Fiddle
    I’ve edited your fiddle slightly to give different sizes to the images for better testing.

    I tried making a solution with .position() but it gave weird results, so detach the lis > 2, get the .scroller‘s outerHeight with solely the first 3 lis and reattach the detached lis is the best solution I can imagine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This sounds like such an obvious thing but I am having a lot of
This sounds like such a dumb question but I've spent too long looking for
This sounds like a relatively simple question, but I haven't been able to get
This sounds like a really simple question, but I am new to PHP. If
This sounds like a problem many others have posted about, but there's a nuance
I know this sounds like a homework assignment, but it isn't. Lately I've been
I know it probably sounds like very trivial question but I couldn't find any
This probably sounds like a terrible idea at first glance, but here is my
I know this sounds like a dumb question but I need to ask this.
This may sounds like a stupid question but can't find anything on google, probably

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.