Skip to content

Instantly share code, notes, and snippets.

@ryderr
Created January 28, 2013 17:37
Show Gist options
  • Save ryderr/4657458 to your computer and use it in GitHub Desktop.
Save ryderr/4657458 to your computer and use it in GitHub Desktop.
simple jquery gallery
$(document).ready(function() {
$(".pic").on("click", function(e){
e.preventDefault();
$("#content").find('li').removeClass("opened");
$(this).addClass("opened");
});
$(".next").on("click", function(e){
e.preventDefault();
var nextthing = $("#content li.opened").next('li');
if (nextthing.length) {
nextthing.addClass("opened");
$("#content li.opened").prev('li').removeClass("opened");
}
else {
$("#content li").first('li').addClass("opened");
$("#content li").last('li').removeClass("opened");
}
});
$(".prev").on("click", function(e){
e.preventDefault();
$("#content li.opened").prev('li').addClass("opened");
$("#content li.opened").next('li').removeClass("opened");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment