Last active
June 14, 2018 14:40
-
-
Save jeangontijo/b19b6ca373276944ea49726b7c4c1dd7 to your computer and use it in GitHub Desktop.
setInterval Change Class
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 slider = document.getElementById("hero"); | |
var classes = ['slide1', 'slide2', 'slide3', 'slide4']; | |
var myInterval = setInterval(function () { | |
changeClass() | |
}, 5000); | |
var i = 0; | |
function changeClass() { | |
slider.classList = classes[i]; | |
i < classes.length - 1 ? i++ : i = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment