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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:10:59+00:00 2026-06-15T21:10:59+00:00

I have a HTML document with the following markup: <div id=outside> <div id=warning>Some warning

  • 0

I have a HTML document with the following markup:

<div id="outside">
<div id="warning">Some warning here</div>
<div id="inside"></div>
</div>

What I would like to do is this list of things, in the order listed, without proceeding to the next item before the prior is complete:

  1. Hide the #outside element.
  2. Set the contents of #inside to “foo”.
  3. Show the #outside element.

Something like this could be done with jQuery:

$('#outside').hide(function(){
    $('#inside').html('bar');
    $('#outside').show();
});

This code gets more confusing as more events include callbacks, and becomes not easily maintainable.

Instead, I would like to do something like this:

$.sequence(
    function(){ $('#outside').hide(); },
    function(){ $('#inside').html('foo'); },
    function(){ $('#outside').show(); }
);

This code clearly shows each step of the process, and allows easy insertion/removal of any step because it doesn’t require nested function callbacks.

Note that the HTML shown here is radically simplified from what I am actually using, and the chain of actions I would like to apply to those elements longer.

Normally, this would be possible merely with sequential method calls on the same jQuery element, but there are different elements in use which don’t allow the queues to execute in order. I’m looking for a way to sequence calls that looks clean when read and works with any elements.

  • 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-15T21:11:00+00:00Added an answer on June 15, 2026 at 9:11 pm

    In this particular example, It’s relatively easy. You can get your desired results with:

    $('#outside').hide();
    $('#inside').html('foo');
    $('#outside').show();
    

    However, if you throw in asynchrounous events, this obviously won’t work. Lets say you instead wanted to get ‘foo’ with ajax. This would be a relatively common way of doing it.

    // request for content immediately
    var req = $.get("myfile.php");
    // fade out container
    $("#outside").fadeOut(function(){
    
        // now that the container is faded out, we
        // bind to the done callback of the request
        // so that we can use the response and fadeIn the container
        // as soon as possible without causing an abrupt stop of the animation
        // if the request finishes early (it most likely will).
        req.done(function(response){
            $("#inside").html(response);
            $("#outside").fadeIn();
        });
    });
    

    Nothing about that is hard to read unless you just aren’t used to using deferred objects. It results in a small amount of code that retrieves and displays the content as fast as possible with subtle animations.

    You could of course abstract this method behind a function if you REALLY want to make it “look better”, but it may end up being less maintainable (Where did i define that function?)

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

Sidebar

Related Questions

I have the following code. It works in an html document. I would like
I have an HTML document where I would like to semantically group text to
I have the following structure of my HTML document: <div id=slideshow></div> <div id=content></div> $('#slideshow').css({
I have an HTML Document that looks a bit like this, only is far
Let's say we have the following list in an HTML document: <ul id=menu> <li><a
I have an unordered list (each list element contains some further markup but this
I have a HTML document with the following markup: <LINK REL=STYLESHEET HREF=c87d971ab8bc48ee87f9ced1b1d5c6e2.css CHARSET=ISO-8859-1 TYPE=text/css>
I have an HTML document and I would like to find the HTML element
I have an HTML document with the following code <html> <head></head> <body> <div id=wrapper>
I have a HTML/XML document similar to the following. There can be one or

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.