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 6950823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:08:25+00:00 2026-05-27T14:08:25+00:00

I have a UL with an overflow-y:scroll; set so it scrolls. How to I

  • 0

I have a UL with an overflow-y:scroll; set so it scrolls. How to I get the full height of the list as $(ul).height() just gives the height of the scroll viewport not the height of the full list.

html

<ul style="overflow-y:scroll; height: 50px;">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

Things like Get The Full Height Of HTML Element That's Partially Hidden By Overflow:Hidden With JQuery / Javascript wont work as there is no inner wrapper, there is just the list.

I’m trying to get the list to scroll to the bottom when I append a new item, but…

$("ul").attr({ scrollTop: NeedHeightHere });

  • 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-05-27T14:08:26+00:00Added an answer on May 27, 2026 at 2:08 pm

    Use the scrollHeight DOM property, supported by all modern browsers (even by IE):

    var wholeHeight = $("ul")[0].scrollHeight;
    

    Alternatively, you can select the first and last item in the list, get the top offset, and substract these from each other. Add the height of the final list element, and the result is equivalent to the scrollHeight (after adding top and bottom paddings of UL).

    var ul = $("ul"),
        last = ul.children().last();
    var wholeHeight = last.offset().top - ul.children().first().offset().top
                      + last.outerHeight()
                      + parseFloat(ul.css("padding-top"))
                      + parseFloat(ul.css("padding-bottom"));
    

    Note: The first method is much more efficient. The second method might fail to produce the right result when the last element is absolutely positioned, or floating.

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

Sidebar

Related Questions

Suppose I have the following html: <div style=width:200px;height:200px;overflow:scroll> ... </div> If the stuff in
I have set a fix height of DIV and set its overflow-y:scroll but the
if have the following code: <div id=container style=position:relative; width:300px; height:300px; overflow:scroll;> <div id=header> </div>
I have a div which is set to overflow:scroll;. I get scrollbars which is
I have a html table with scrollbar (i.e. overflow is set). When I scroll
I have defined a tag with a CSS attribute overflow set to scroll. This
I have form that has a restricted size and the overflow style set to
I have a UITextField but when it overflows I want it to scroll not
I have a div that's set to overflow: auto; . This contents of this
I have a div container set to overflow:auto which contains many <li> 's. I

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.