Created
December 8, 2014 23:04
-
-
Save ckhatton/c5ba534a0fbb09ae74d4 to your computer and use it in GitHub Desktop.
Alternately change a snippet of text in the DOM.
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
var customInterval = null; | |
function changeText(elem, text) { | |
// 'text' is a array of strings | |
// For example: ['loading','.loading.','..loading..','...loading...'] | |
var counter = 0; | |
customInterval = setInterval(change, 1000); | |
function change() { | |
elem.text(text[counter]); | |
counter++; | |
if(counter >= text.length) { counter = 0; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment