How to show divs in order?How do JavaScript closures work?How do I detect a click outside an element?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Please figure out this Pan digital Prince

Shouldn't Apple consider allowing use of Apple Pencil while it's charging?

Was Self-modifying-code possible just using BASIC?

2019 gold coins to share

What would be the way to say "just saying" in German? (Not the literal translation)

Russian word for a male zebra

Why does this query, missing a FROM clause, not error out?

Is there a DSLR/mirorless camera with minimal options like a classic, simple SLR?

What does the pair of vertical lines in empirical entropy formula mean?

Should I refuse to be named as co-author of a low quality paper?

Why are MBA programs closing in the United States?

Smart-expansion of a range to a list of numbers

What would prevent chimeras from reproducing with each other?

If a Variant Human is Reincarnated, would they lose the feat and skill proficiency they started with?

Why can my keyboard only digest 6 keypresses at a time?

What STL algorithm can determine if exactly one item in a container satisfies a predicate?

Is it safe to change the harddrive power feature so that it never turns off?

Origin of "boor"

How can one's career as a reviewer be ended?

Varying the size of dots in a plot according to information contained in list

Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?

Ability To Change Root User Password (Vulnerability?)

Is using 'echo' to display attacker-controlled data on the terminal dangerous?

Why is long-term living in Almost-Earth causing severe health problems?



How to show divs in order?


How do JavaScript closures work?How do I detect a click outside an element?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I'm creating a website just for myself, and want to make divs with text appear in order (some interval between appearance will be great) after the page will load. I don't need any special animation.



I tried to find something on Stack Overflow or anywhere else, but I couldn't. It should be some kind of "copy" of messenger.



Here is what I got:






<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>





https://jsfiddle.net/2p860Lxt










share|improve this question
























  • look up css animations

    – ecg8
    Mar 24 at 20:45

















-1















I'm creating a website just for myself, and want to make divs with text appear in order (some interval between appearance will be great) after the page will load. I don't need any special animation.



I tried to find something on Stack Overflow or anywhere else, but I couldn't. It should be some kind of "copy" of messenger.



Here is what I got:






<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>





https://jsfiddle.net/2p860Lxt










share|improve this question
























  • look up css animations

    – ecg8
    Mar 24 at 20:45













-1












-1








-1








I'm creating a website just for myself, and want to make divs with text appear in order (some interval between appearance will be great) after the page will load. I don't need any special animation.



I tried to find something on Stack Overflow or anywhere else, but I couldn't. It should be some kind of "copy" of messenger.



Here is what I got:






<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>





https://jsfiddle.net/2p860Lxt










share|improve this question
















I'm creating a website just for myself, and want to make divs with text appear in order (some interval between appearance will be great) after the page will load. I don't need any special animation.



I tried to find something on Stack Overflow or anywhere else, but I couldn't. It should be some kind of "copy" of messenger.



Here is what I got:






<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>





https://jsfiddle.net/2p860Lxt






<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>





<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>






javascript jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 21:05









aldi

5431519




5431519










asked Mar 24 at 20:40









RadoslavRadoslav

32




32












  • look up css animations

    – ecg8
    Mar 24 at 20:45

















  • look up css animations

    – ecg8
    Mar 24 at 20:45
















look up css animations

– ecg8
Mar 24 at 20:45





look up css animations

– ecg8
Mar 24 at 20:45












2 Answers
2






active

oldest

votes


















0














You could first hide them with CSS (for instance with display: none in the .message class), and then use the promise returned by .delay().promise() to show them with delay, and chain those promises with reduce:






$(".message").get().reduce(function (acc, div) 
return acc.then(function ()
return $(div).show().delay(400).promise();
);
, $.when()); // start with a resolved promise

.message display: none ;

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<div class="messages-area">
<div class="message bubbledLeft">
<p>Hey!</p>
</div>
<div class="message bubbledLeft last-bubbled-left">
<p>Did you hear about it?</p>
</div>
<div class="message bubbledRight last-bubbled-right">
<p>Huh? About what?</p>
</div>
<div class="message bubbledLeft">
<p>About this new website!</p>
</div>
</div>








share|improve this answer






























    0














    You don't need jQuery for this. Here's how you could do it with plain JavaScript:



    HTML:



    <div id="message-area"></div>


    JavaScript:



    function addMessage() 
    var container = document.getElementById("message-area");
    var messageElem = document.createElement("div");
    messageElem.setAttribute("class", "message-area__message");
    messageElem.appendChild(document.createTextNode("my message"));
    container.appendChild(messageElem);


    window.addEventListener('load', function()
    console.log('loaded')
    for (var i=0; i<5; i++)
    window.setTimeout(addMessage, 500*i);

    );


    This will add 5 message elements into the message area, 500 milliseconds apart.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328362%2fhow-to-show-divs-in-order%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You could first hide them with CSS (for instance with display: none in the .message class), and then use the promise returned by .delay().promise() to show them with delay, and chain those promises with reduce:






      $(".message").get().reduce(function (acc, div) 
      return acc.then(function ()
      return $(div).show().delay(400).promise();
      );
      , $.when()); // start with a resolved promise

      .message display: none ;

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
      <div class="messages-area">
      <div class="message bubbledLeft">
      <p>Hey!</p>
      </div>
      <div class="message bubbledLeft last-bubbled-left">
      <p>Did you hear about it?</p>
      </div>
      <div class="message bubbledRight last-bubbled-right">
      <p>Huh? About what?</p>
      </div>
      <div class="message bubbledLeft">
      <p>About this new website!</p>
      </div>
      </div>








      share|improve this answer



























        0














        You could first hide them with CSS (for instance with display: none in the .message class), and then use the promise returned by .delay().promise() to show them with delay, and chain those promises with reduce:






        $(".message").get().reduce(function (acc, div) 
        return acc.then(function ()
        return $(div).show().delay(400).promise();
        );
        , $.when()); // start with a resolved promise

        .message display: none ;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
        <div class="messages-area">
        <div class="message bubbledLeft">
        <p>Hey!</p>
        </div>
        <div class="message bubbledLeft last-bubbled-left">
        <p>Did you hear about it?</p>
        </div>
        <div class="message bubbledRight last-bubbled-right">
        <p>Huh? About what?</p>
        </div>
        <div class="message bubbledLeft">
        <p>About this new website!</p>
        </div>
        </div>








        share|improve this answer

























          0












          0








          0







          You could first hide them with CSS (for instance with display: none in the .message class), and then use the promise returned by .delay().promise() to show them with delay, and chain those promises with reduce:






          $(".message").get().reduce(function (acc, div) 
          return acc.then(function ()
          return $(div).show().delay(400).promise();
          );
          , $.when()); // start with a resolved promise

          .message display: none ;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
          <div class="messages-area">
          <div class="message bubbledLeft">
          <p>Hey!</p>
          </div>
          <div class="message bubbledLeft last-bubbled-left">
          <p>Did you hear about it?</p>
          </div>
          <div class="message bubbledRight last-bubbled-right">
          <p>Huh? About what?</p>
          </div>
          <div class="message bubbledLeft">
          <p>About this new website!</p>
          </div>
          </div>








          share|improve this answer













          You could first hide them with CSS (for instance with display: none in the .message class), and then use the promise returned by .delay().promise() to show them with delay, and chain those promises with reduce:






          $(".message").get().reduce(function (acc, div) 
          return acc.then(function ()
          return $(div).show().delay(400).promise();
          );
          , $.when()); // start with a resolved promise

          .message display: none ;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
          <div class="messages-area">
          <div class="message bubbledLeft">
          <p>Hey!</p>
          </div>
          <div class="message bubbledLeft last-bubbled-left">
          <p>Did you hear about it?</p>
          </div>
          <div class="message bubbledRight last-bubbled-right">
          <p>Huh? About what?</p>
          </div>
          <div class="message bubbledLeft">
          <p>About this new website!</p>
          </div>
          </div>








          $(".message").get().reduce(function (acc, div) 
          return acc.then(function ()
          return $(div).show().delay(400).promise();
          );
          , $.when()); // start with a resolved promise

          .message display: none ;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
          <div class="messages-area">
          <div class="message bubbledLeft">
          <p>Hey!</p>
          </div>
          <div class="message bubbledLeft last-bubbled-left">
          <p>Did you hear about it?</p>
          </div>
          <div class="message bubbledRight last-bubbled-right">
          <p>Huh? About what?</p>
          </div>
          <div class="message bubbledLeft">
          <p>About this new website!</p>
          </div>
          </div>





          $(".message").get().reduce(function (acc, div) 
          return acc.then(function ()
          return $(div).show().delay(400).promise();
          );
          , $.when()); // start with a resolved promise

          .message display: none ;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
          <div class="messages-area">
          <div class="message bubbledLeft">
          <p>Hey!</p>
          </div>
          <div class="message bubbledLeft last-bubbled-left">
          <p>Did you hear about it?</p>
          </div>
          <div class="message bubbledRight last-bubbled-right">
          <p>Huh? About what?</p>
          </div>
          <div class="message bubbledLeft">
          <p>About this new website!</p>
          </div>
          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 21:20









          trincottrincot

          136k16100137




          136k16100137























              0














              You don't need jQuery for this. Here's how you could do it with plain JavaScript:



              HTML:



              <div id="message-area"></div>


              JavaScript:



              function addMessage() 
              var container = document.getElementById("message-area");
              var messageElem = document.createElement("div");
              messageElem.setAttribute("class", "message-area__message");
              messageElem.appendChild(document.createTextNode("my message"));
              container.appendChild(messageElem);


              window.addEventListener('load', function()
              console.log('loaded')
              for (var i=0; i<5; i++)
              window.setTimeout(addMessage, 500*i);

              );


              This will add 5 message elements into the message area, 500 milliseconds apart.






              share|improve this answer



























                0














                You don't need jQuery for this. Here's how you could do it with plain JavaScript:



                HTML:



                <div id="message-area"></div>


                JavaScript:



                function addMessage() 
                var container = document.getElementById("message-area");
                var messageElem = document.createElement("div");
                messageElem.setAttribute("class", "message-area__message");
                messageElem.appendChild(document.createTextNode("my message"));
                container.appendChild(messageElem);


                window.addEventListener('load', function()
                console.log('loaded')
                for (var i=0; i<5; i++)
                window.setTimeout(addMessage, 500*i);

                );


                This will add 5 message elements into the message area, 500 milliseconds apart.






                share|improve this answer

























                  0












                  0








                  0







                  You don't need jQuery for this. Here's how you could do it with plain JavaScript:



                  HTML:



                  <div id="message-area"></div>


                  JavaScript:



                  function addMessage() 
                  var container = document.getElementById("message-area");
                  var messageElem = document.createElement("div");
                  messageElem.setAttribute("class", "message-area__message");
                  messageElem.appendChild(document.createTextNode("my message"));
                  container.appendChild(messageElem);


                  window.addEventListener('load', function()
                  console.log('loaded')
                  for (var i=0; i<5; i++)
                  window.setTimeout(addMessage, 500*i);

                  );


                  This will add 5 message elements into the message area, 500 milliseconds apart.






                  share|improve this answer













                  You don't need jQuery for this. Here's how you could do it with plain JavaScript:



                  HTML:



                  <div id="message-area"></div>


                  JavaScript:



                  function addMessage() 
                  var container = document.getElementById("message-area");
                  var messageElem = document.createElement("div");
                  messageElem.setAttribute("class", "message-area__message");
                  messageElem.appendChild(document.createTextNode("my message"));
                  container.appendChild(messageElem);


                  window.addEventListener('load', function()
                  console.log('loaded')
                  for (var i=0; i<5; i++)
                  window.setTimeout(addMessage, 500*i);

                  );


                  This will add 5 message elements into the message area, 500 milliseconds apart.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 24 at 20:53









                  jknotekjknotek

                  453512




                  453512



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328362%2fhow-to-show-divs-in-order%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript