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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:30:04+00:00 2026-06-04T07:30:04+00:00

quick question. im trying to animate a few things with jquery and although its

  • 0

quick question. im trying to animate a few things with jquery and although its working, this is the problem im having.

well first heres the code:

$(document).ready( function(e){

    // vars
    var question = $('#faqQues');
    var answer = $('#faqAns');  
    var ansCont = $('#faqAnsCont');


    question.click(function(){
         if (answer.css("display") != "none") {
             answer.animate({'height':0}, 500, hmm);

             function hmm() {
                 answer.css("display","none");  
             } 
         } else {
             answer.css("display","block");
             answer.animate({"height":'100'},500);  
         }
    });
});

essentially all i want to do be able to click something and it animate its height(up down).
the problem comes in on this code block

else {
    answer.css("display","block");
    answer.animate({"height":'100'},500);               
}

specifically on this line

{"height":'100'}

what i want to happen is that it animates back to the divs default height. I dont want to
add a number (like the 100 above) height because the divs inner content is always going to change hence the dynamic height but if i remove the height, it breaks. Ive tried a few other things including something like maybe

.animate({"height":'**divNameHere**.height()'},500);

but although it dont get errors, it doesnt work either lol.

So here i am asking for help. what changes do i need to make to this so that it animates back to whatever that divs height is without directly putting in a number?

Any Tips, code, links etc i’ll gladly appreciate

  • 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-04T07:30:05+00:00Added an answer on June 4, 2026 at 7:30 am

    Why don’t you use the slideUp() and slideDown() methods which do exactly what you want ?

    Or better yet slideToggle() which handles both ways automatically ?

    $(document).ready(function(e) {
        // vars
        var question = $('#faqQues');
        var answer = $('#faqAns');
        var ansCont = $('#faqAnsCont');
    
        question.click(function() {
            answer.slideToggle(500);
        });
    });
    

    Demo at http://jsfiddle.net/5wBeu/

    That is all you need..

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

Sidebar

Related Questions

quick question. I am trying to use either javascript, jquery, or php to make
Good Morning, Just a quick question what this field actually means? I am trying
Hi guys just a quick question, After having a nightmare trying to get an
Hey guys, quick question, just trying to filter a user's first and last name
I've got a (hopefully) quick question this time, although it's been troubling me for
Just getting started with Powershell and have a quick question. Trying to run this
Quick question, I'm trying to pass a value to a variable and then run
Quick question hopefully someone can help out here. I'm trying to copy and paste
Quick question... I have a query that checks for duplicates that looks like this:
Quick question. I have an app that use a native DLL through PInvoke, this

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.