Skip to content

Instantly share code, notes, and snippets.

@rpong
Last active September 29, 2015 06:52
Show Gist options
  • Save rpong/0709831570e210a70003 to your computer and use it in GitHub Desktop.
Save rpong/0709831570e210a70003 to your computer and use it in GitHub Desktop.
rotateImage.js
setInterval(function(){
$('.fleft').each(function() {
var randVal = Math.floor((Math.random() * 10) + 1);
if (randVal == 1 || randVal == 7) {
return;
}
if (this.src != undefined) {
var randVal = Math.floor((Math.random() * 2) + 1);
switchFrom = '_' + randVal + '_';
if (randVal == 1) {
switchTo = '_2_';
} else {
switchTo = '_1_';
}
$(this).fadeOut('slow', function () {
$(this).attr("src",this.src.replace(switchFrom, switchTo));
$(this).fadeIn('slow');
});
}
});
},5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment