Last active
February 25, 2021 06:06
-
-
Save say2joe/4569319 to your computer and use it in GitHub Desktop.
Element loading message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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