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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:40:19+00:00 2026-05-29T06:40:19+00:00

I have 3 divs. When you click HIDE on divChaptersHide (div1) it will be

  • 0

I have 3 divs. When you click “HIDE” on divChaptersHide (div1) it will be hidden to reveal another div (divChaptersExpand) that has a smaller width. When you then click on “EXPAND” on divChaptersExpand it hides that div and then reveals divChaptersHide again. You can also do all of this with div 3 (divPowerPointExpand). The problem I am having is that I need div 2 to stretch the entire width of the available space when the text in div 1 (or div 3) is clicked on. Thanks for the help!

HTML

<div style="margin:0 auto">
<!--CHAPTERS DIV-->
<div id="divChaptersHide" style="width:20%;background:black;color:white;float:left;height:300px;">
    <div style="padding:0 10px"><p id="chaptersHideText" style="text-align:right">HIDE</p></div>
</div>
    <!--POWERPOINT EXPAND DIV-->
    <div id="divChaptersExpand" style="display:none;width:100px;background:black;color:white;float:left;height:300px;">
        <p id="chaptersExpandText" >EXPAND</p>
    </div>
<!--VIDEO DIV-->
<div id="divMainVideo" style="width:60%;background:purple;color:white;float:left;height:300px"></div>
<!--POWERPOINT DIV-->
<div id="divPowerPointHide" style="width:20%;background:black;color:white;float:right;height:300px">
    <div style="padding:0 10px"><p id="powerPointHideText" style="text-align:left"><a>HIDE</a></p></div>
</div>
    <!--POWERPOINT EXPAND DIV-->
     <div id="divPowerPointExpand" style="display:none;width:100px;background:black;color:white;float:right;height:300px;">
        <p id="powerPointExpandText" >EXPAND</p>
    </div>

jQuery

$(function(){
        chaptersHide();    
        powerPointHide();
        expandChapters();
        expandPowerPoint();
    });

function chaptersHide(){
        $("#chaptersHideText").click(function(){
            $("#divChaptersHide").hide("scale", {percent:0, origin: 'top'}, 500);
            setTimeout(function(){$('#divChaptersExpand').show("drop",{direction:'left'},500)}, 500);
        });
    }

function powerPointHide(){
        $("#powerPointHideText").click(function(){
            $("#divPowerPointHide").hide("scale", {percent:0, origin: 'top'}, 500)
            setTimeout(function(){$('#divPowerPointExpand').show("drop",{direction: 'right'},500)},500);
        });
    }

function expandChapters(){
        $('#chaptersExpandText').click(function(){
            $('#divChaptersExpand').hide("drop", { direction: "left" }, 500);
            setTimeout(function(){$('#divChaptersHide').show("scale", {origin:'top'}, 500)},500);
            });
    }

function expandPowerPoint(){
    $('#powerPointExpandText').click(function(){
            $('#divPowerPointExpand').hide("drop", { direction: "right" }, 500);
            setTimeout(function(){$('#divPowerPointHide').show("scale", {origin:'top'}, 500)},500);
            });
    }

JSFiddle

  • 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-29T06:40:20+00:00Added an answer on May 29, 2026 at 6:40 am

    I edited your JsFiddle to accomplish what you are trying to do.

    I nested another “setTimeout()” function within your existing ones that ‘dynamically’ resizes your main divs.

    This solution is a patch job, but it will give you an idea of how to accomplish creating a ‘callback’ function for each of your setTimeout() functions.

    UPDATE:
    Here is the fiddle example without the setTimeout() functions and with a smoother transition. If you still see the glitch where EXPAND pushes the POWERPOINT div down, just subtract more than 200px from the ‘reducedWidth’ variable.

    $(function(){
            chaptersHide();    
            powerPointHide();
            expandChapters();
            expandPowerPoint();
        });
    function chaptersHide(){
            $("#chaptersHideText").click(function(){
                $("#divChaptersHide").hide("scale", {percent:0, origin: 'top'}, 500, function(){
                    $('#divChaptersExpand').show("drop",{direction:'left'},500, function(){
                        setVideoWidth(); 
                    });
                });
    
            });
    
        }
    function powerPointHide(){
            $("#powerPointHideText").click(function(){
                $("#divPowerPointHide").hide("scale", {percent:0, origin: 'top'}, 500, function(){
                    $('#divPowerPointExpand').show("drop",{direction: 'right'},500, function(){
                        setVideoWidth();
                    });
                });
            });
        }
    function expandChapters(){
            $('#chaptersExpandText').click(function(){
                var reducedWidth = $('#divMainVideo').width() - 200;
                $('#divMainVideo').animate( { width: reducedWidth }, 500 );
                $('#divChaptersExpand').hide("drop", { direction: "left" }, 500, function(){
                    $('#divChaptersHide').show("scale", {origin:'top'}, 500, function(){
                        setVideoWidth(); 
                    });
                });
            });
        }
    function expandPowerPoint(){
        $('#powerPointExpandText').click(function(){
            var reducedWidth = $('#divMainVideo').width() - 200;
            $('#divMainVideo').animate( { width: reducedWidth }, 500 );
            $('#divPowerPointExpand').hide("drop", { direction: "right" }, 500, function(){
                $('#divPowerPointHide').show("scale", {origin:'top'}, 500, function(){
                    setVideoWidth(); 
                });
            });
        });
    }
    
    function setVideoWidth(){
        var total = getCurrentTotalWidth();
        var chapters = getCurrentChaptersWidth();
        var powerpoint = getCurrentPowerpointWidth();
        var video = $('#divMainVideo').width();
    
        var space = total - chapters - powerpoint - video;
        var newWidth = space + video;
        $('#divMainVideo').animate( { width: newWidth }, 250 );
    }
    
    function getCurrentTotalWidth(){
        return $('div:first').width();
    }
    function getCurrentChaptersWidth(){
        if( $("#divChaptersHide").css('display') !== "none" ){
            return $("#divChaptersHide").width()
        }
        else{
            return $('#divChaptersExpand').width();
        }
    }
    function getCurrentPowerpointWidth(){
        if( $("#divPowerPointHide").css('display') !== "none" ){
            return $("#divPowerPointHide").width()
        }
        else{
            return $('#divPowerPointExpand').width();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some DIVs that I am using JQuery to hide and show using
I have hidden Divs with .display-link classes that are two levels up from an
(Jquery) I have two divs that I'm toggling back and forth (show and hide)
I have a slider that bounces back and forth between divs when you click
I have 2 divs which I show or hide depending on a button click
this is kinda tricky to explain,but here goes....I have multiple hidden divs that swap
I have a menu and three hidden divs that show up depending on what
I have a container that has several divs with content. i need to be
I have multiple links that show/hide divs throughout (using slideDown() ). Each of the
I have a series of divs that are hidden and I would like to

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.