Skip to content

Instantly share code, notes, and snippets.

@Synvox
Created March 4, 2016 15:47
Show Gist options
  • Save Synvox/6a896f4213cd4633d60e to your computer and use it in GitHub Desktop.
Save Synvox/6a896f4213cd4633d60e to your computer and use it in GitHub Desktop.
<div class="phrases">
<div class="phrase">First</div>
<div class="phrase">Second</div>
<div class="phrase">Third</div>
<div class="phrase">Fourth</div>
</div>
<script>
;(function(){
var timeout = 1000,
index = 0,
phrases = Array.prototype.slice.call(
document.querySelectorAll('.phrase')
)
phrases.forEach(function(ele){
ele.style.display = 'none'
})
window.setInterval(function(){
phrases.forEach(function(ele){
ele.style.display = 'none'
})
phrases[index].style.display = 'block'
index++
if (index === phrases.length) index = 0
}, timeout)
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment