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;
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
javascript jquery
add a comment |
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
javascript jquery
look up css animations
– ecg8
Mar 24 at 20:45
add a comment |
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
javascript jquery
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
javascript jquery
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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>
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
add a comment |
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>
add a comment |
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>
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>
answered Mar 24 at 21:20
trincottrincot
136k16100137
136k16100137
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 24 at 20:53
jknotekjknotek
453512
453512
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
look up css animations
– ecg8
Mar 24 at 20:45