Skip to content

Instantly share code, notes, and snippets.

@say2joe
Last active February 25, 2021 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save say2joe/4569319 to your computer and use it in GitHub Desktop.
Save say2joe/4569319 to your computer and use it in GitHub Desktop.
Element loading message
// Sets the html of an element with "Loading ..." and continues to print a dot up to 20 times.
// If the element is ready to be updated with actual content, simply clearInterval($el[0].interval);
// Requires: jQuery v1.4+
$el.html(function(i,html){
this.intcount = 0;
this.interval = ($.proxy(function(el){
return setInterval(function(){
if (++el.intcount < 20) el.innerHTML += '.';
else clearInterval(el.interval);
}, 500);
}, this))(this);
return "Loading ...";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment