A very simple "loading ..." animation in 5 lines of JavaScript
Here's a way to do a really simple "loading ..." animation, in just 5 lines of JavaScript
i = 0;
setInterval(function() {
i = ++i % 4;
$("#loading").html("Loading "+Array(i+1).join("."));
}, 800);
Working JavaScript Demo on codepen.io
For the lazy, who don't want to go over to codepen.io and see the actual working JavaScript demo. Here's an animated gif that will give you an idea of what it looks like.
Written by James Barnett
Related protips
2 Responses
Hello James,
this is as simple as really nice and useful.
I would like to use it in my site, and display it meanwhile the page is loading, but I don't really know how to do that :O
Could you please give me an hand?
Cheers, MT
over 1 year ago
·
Well that is very nice.
I made minor changes to make it pure JS and actually added some style to it.
http://codepen.io/dvLden/pen/uHBpe/
Regards,
Nenad - dvLden
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#