Skip to content

Instantly share code, notes, and snippets.

@danest
Created December 29, 2011 18:43
Show Gist options
  • Save danest/1535514 to your computer and use it in GitHub Desktop.
Save danest/1535514 to your computer and use it in GitHub Desktop.
<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