Created
December 29, 2011 18:43
-
-
Save danest/1535514 to your computer and use it in GitHub Desktop.
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
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var timer; | |
function changeIndex(){ | |
$('li').each(function(i){ | |
//console.log($(this).width()); | |
//change z-index on every hover | |
$(this).css('z-index',Math.floor(Math.random() * 30)); | |
}); | |
} | |
$('#holder').hover(function(){ | |
timer = setInterval(changeIndex, 100); | |
}, function(){ | |
//reset to stop and set z-index back to 0 on all | |
//this makes the last image always show first | |
clearInterval(timer); | |
$('li').each(function(i){ | |
$(this).css('z-index',0); | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment