Skip to content

Instantly share code, notes, and snippets.

@jthacker
Created February 2, 2011 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthacker/807086 to your computer and use it in GitHub Desktop.
Save jthacker/807086 to your computer and use it in GitHub Desktop.
function f() {
i=0;
d=['n','s'];
// Call the first argument at an interval of 150ms
setInterval(function() {
$('.eye').each(function() { // Find all elements with a class of eye
// for each element change the src attribute to either the North or South image
// img_base is defined in the lateral-eye.js file from the webpage
$(this).attr('src',img_base+$(this).attr('rel')+'_'+d[i]+'.jpg')
});
// Toggles the image between n and s
// i = 0 to start
// (0 + 1) mod 2 == 1
// (1 + 1) mod 2 == 0
i = (i+1) % d.length;
},150);
}
f()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment