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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:12:59+00:00 2026-06-17T06:12:59+00:00

I need a div B on my website to update dynamically according to the

  • 0

I need a div B on my website to update dynamically according to the run time changing height of another div A. div A uses the jquery slideToggle() [on several divs inside the div A], but div B should only be changing (at the same time) to match the current height of div A. panel_toggle1 and panel1 are contained inside div A:

$(document).ready(function () {
    $("#panel_toggle1").click(function () {
        $("#panel1").slideToggle("slow", function () {
            var divAheight = $("#divA").height();
            $("#divB").animate({ height: divAheight }, "slow");
        });
    });
});

The above code does basely what I wanted, however, due to the callback(), it waits for the slideToggle() to finish before doing the slide effect on the other div (I was forced to do this because sliteToggle() does not spit out the final height() of div A until it finishes).

Is there a way to do this so that both div A and div B update smoothly at the same time?
i.e. Is there a way to get the height slideToggle() will update div A before it finishes (so that I can just call .animate() on div B the same time as on div A)?

Note: I don’t use fixed heights for any divs in the CSS, I would like to keep it simple

Alternatively, is there a way I can keep div B to match div A‘s height with just CSS?

  • 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-17T06:13:00+00:00Added an answer on June 17, 2026 at 6:13 am

    If you are able to set a fixed target height of your divA, the solution would be trivial, you’d just need to set your animations to run simultaneously, e.g. by setting queue=false.

    Since it seems like you want to run these animations simultaneously without knowing the resulting height of the original animation, a workaround is to use two animations to acheive the effect:

    var $divB = $("#divB");
    $divB.animate({
       height: '600px' // some arbitrary height approaching target height
    }, { duration: 5000 /* longer than the next animation */, queue: false });
    $("#panel1").slideToggle({
       duration: 'slow', 
       queue: false,
       complete: function () {
           var divAheight = $("#divA").height();
           // stop the animation and begin another with the correct target height
           $divB.stop().animate({ height: divAheight }, "slow");
       }
    });
    

    Here, both divs begin to animate at the same time. When the slideToggle animation completes, the code stops the height animation of divB and begins a new height animation of divB = height of divA. Kinda hacky, but you have to wait until the first animation completes to get the updated height.

    The other option would be to perform a calculation to get the height of the result of the slideToggle and then run simultaneous animations:

    var newHeight = $("#divA").height() - $("#panel1").height(); 
    var $divB = $("#divB");
    $divB.animate({
       height: newHeight + 'px'
    }, { duration: 'slow', queue: false });
    $("#panel1").slideToggle({
       duration: 'slow', 
       queue: false
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a div css boxes every time with html-php content, when its in
I am using facebox which uses jQuery 1.2.1 on my website here http://www.pointclickshoot.com/beta2 The
I have to modify a website that another developer wrote. I need the font
ok lets say we have a website that need a realtime time; example :
i try to load a div from another website but when i load, img
I have a website where I need to have a specific header div display
I need a div with picture bg to overlay an image (with some amount
I need a div to be disabled (so that it no longer receives click)
I need three tables (div). The left and right sides of the occupied 50%
I need to hide div 'email' content if the div 'name' is empty. 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.