Skip to content

Instantly share code, notes, and snippets.

@adrianrodriguez
Created October 19, 2011 16:33
Show Gist options
  • Save adrianrodriguez/1298855 to your computer and use it in GitHub Desktop.
Save adrianrodriguez/1298855 to your computer and use it in GitHub Desktop.
$(function() {
$(".grid_3").each(function(){
// .next finds the next Dom element in this case it would be another grid_3 element
var next = $(this).next();
var prev = $(this).prev();
// Store this current element into a var called "that" so that "this" can be used in it's own handler
var that = this;
// Find the .next element in this specific element and call a click function
$(this).find('.next').click(function() {
// Hide the current parent element the variable set above for the grid_3 element
$(that).hide();
// Fade in the next element in the dom
next.fadeIn();
});
// Reverse that sucka
$(this).find('.prev').click(function() {
$(that).hide();
prev.fadeIn();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment