Created
January 28, 2013 17:37
-
-
Save ryderr/4657458 to your computer and use it in GitHub Desktop.
simple jquery gallery
This file contains hidden or 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
$(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