Skip to content

Instantly share code, notes, and snippets.

@kenold
Last active June 27, 2019 19:19
Show Gist options
  • Save kenold/7b1883cfd97cba93d997bbc2aa3a8ab4 to your computer and use it in GitHub Desktop.
Save kenold/7b1883cfd97cba93d997bbc2aa3a8ab4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Text Anim</title>
<style type="text/css">
#word {
background: yellow;
width: 200px;
}
</style>
</head>
<body>
<div id="word">Alpha</div>
<!-- import JQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(function () {
count = 0;
// add text list in quotes
wordsArray = ["Beta <br /> Yo", "Gamma", "Delta", "Alpha"];
intervalId = setInterval(function () {
count++;
if (count === wordsArray.length) {
clearInterval(intervalId);
}
$("#word").fadeOut(400, function () {
$(this).html(wordsArray[count % wordsArray.length]).fadeIn(400);
});
}, 2000); //text duration
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment