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

                      How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                      Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?