Created
October 11, 2018 14:22
-
-
Save jremi/e726515cdbb4c0e603ee8b46207912b5 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
<style id="jsbin-css"> | |
div { | |
width:50px; | |
height:50px; | |
background-color: black; | |
margin-bottom:10px; | |
} | |
.active { | |
background-color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="pic1"></div> | |
<div id="pic2"></div> | |
<div id="pic3"></div> | |
<div id="pic4"></div> | |
<script id="jsbin-javascript"> | |
let lastActive = 0; | |
setInterval(()=>{ | |
$('div').removeClass('active'); | |
if(lastActive === 0){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
else if(lastActive === 1){ | |
$('#pic2').addClass('active'); | |
lastActive = 2; | |
} | |
else if(lastActive === 2){ | |
$('#pic3').addClass('active'); | |
lastActive = 3; | |
} | |
else if(lastActive === 3){ | |
$('#pic3').addClass('active'); | |
lastActive = 4; | |
} | |
else if(lastActive === 4){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
}, 500) | |
</script> | |
<script id="jsbin-source-css" type="text/css">div { | |
width:50px; | |
height:50px; | |
background-color: black; | |
margin-bottom:10px; | |
} | |
.active { | |
background-color: red; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">let lastActive = 0; | |
setInterval(()=>{ | |
$('div').removeClass('active'); | |
if(lastActive === 0){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
else if(lastActive === 1){ | |
$('#pic2').addClass('active'); | |
lastActive = 2; | |
} | |
else if(lastActive === 2){ | |
$('#pic3').addClass('active'); | |
lastActive = 3; | |
} | |
else if(lastActive === 3){ | |
$('#pic3').addClass('active'); | |
lastActive = 4; | |
} | |
else if(lastActive === 4){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
}, 500)</script></body> | |
</html> |
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
div { | |
width:50px; | |
height:50px; | |
background-color: black; | |
margin-bottom:10px; | |
} | |
.active { | |
background-color: red; | |
} |
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
let lastActive = 0; | |
setInterval(()=>{ | |
$('div').removeClass('active'); | |
if(lastActive === 0){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
else if(lastActive === 1){ | |
$('#pic2').addClass('active'); | |
lastActive = 2; | |
} | |
else if(lastActive === 2){ | |
$('#pic3').addClass('active'); | |
lastActive = 3; | |
} | |
else if(lastActive === 3){ | |
$('#pic3').addClass('active'); | |
lastActive = 4; | |
} | |
else if(lastActive === 4){ | |
$('#pic1').addClass('active'); | |
lastActive = 1; | |
} | |
}, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment