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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:43:00+00:00 2026-05-22T18:43:00+00:00

EDIT: I was really tired last night, and wrote my jQuery out wrong, .readMore

  • 0

EDIT: I was really tired last night, and wrote my jQuery out wrong, “.readMore” is always the trigger for it’s respective div’s animation. I apologize.

Hello Everyone,

I would like to extract specific information from elements with the same class. I have multiple divs that contain varying amounts of text, thus, their heights vary as well. However, I have set the class associated with these divs to a height of 200px. At the bottom of each div, I have an absolutely positioned anchor, that allows the reader to expand(animate) the div to it’s automatic/natural height.

What I’d like to do is to find out the ‘auto’ height of the divs with the same class, store it, and then call on it later when a respective div’s anchor is clicked. So far, I keep only getting one value or no value, whereas I’d like all of them.

I’ve been using .each() recently, but to no avail. The real problem seems to be animating the divs, otherwise, it’s no problem; just need to use .css() to set the height to auto. This would be a whole lot easier if you could animate your height to auto. I hope I’m explaining myself correctly. In any case, here’s my code.

HTML

<div class="stretch">
    text
    <a class="readMore">Read More</a>
</div>

<div class="stretch">
    text
    <a class="readMore">Read More</a>
</div>

<div class="stretch">
    text
    <a class="readMore">Read More</a>
</div>

CSS

div.stretch {height:auto; width:100%; overflow:hidden; position:relative}
a.readMore {position:absolute; left:0; bottom:0;}

JQuery

$divheight = //stored height of divs
$allheight = $divheight + 100; //extra space to clear the anchor
$(".h200").height(200);
$(".stretch").addClass("h200"); //change height later, to be able to refer to automatic/natural height

$(".readmore").toggle(
    function(){
        $(this).parent('div').animate({height:$allheight}, 750);
        $(".readMore").text("Read Less");
    },
    function(){
        $(this).parent('div').animate({height:"200px"}, 250);
        $(".readMore").text("Read More");
    }
)

Thanks it advance, I really appreciate you even taking a look.

  • 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-22T18:43:01+00:00Added an answer on May 22, 2026 at 6:43 pm

    try this:

    $hiddenheight=200;
    $extraspace=100;
    
    $(".stretch")
    .each(function(){
        $(this).data('actualheight', $(this).outerHeight()+$extraspace).css('height', $hiddenheight+'px');    //outerHeight for including padding+margin+border, if any
    })
    .toggle(
        function(){
            $(this).animate({height: $(this).data('actualheight')+'px'}, 750);
            $(".readMore").text("Read Less");
        },
        function(){
            $(this).parent('div').animate({height:$hiddenheight+"px"}, 250);
            $(".readMore").text("Read More");
        }
    )
    

    adjust the height values according to needs..

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

Sidebar

Related Questions

Is the documentation for Rich Edit Controls really as bad (wrong?) as it seems
EDIT: I would really like to see some general discussion about the formats, their
Edit : Solved, there was a trigger with a loop on the table (read
EDIT: Why was this voted down? I really have no idea... BTW ../ does
I'm having a really hard time with this one, EDIT: I'm putting this edit
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT: This question is more about language engineering than C++ itself. I used C++

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.