Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJaime Garay
2,998 PointsNext and Previous buttons
hey, can someone help me? the thing is I have this Js code and it works perfect with the overlay, but I'm trying to do a "next" and "previous" buttons inside the overlay to get the next and previous image without closing the overlay...so this is my code and I already added the buttons
//variables
var overlay = $("<div id='overlay'></div>");
var imagen = $("<img>");
var siguiente = $("<button class='next'>next</button>");
var anterior = $("<button class='prev'>Previous</button>");
//overlay to body
$("body").append(overlay);
//overlay
overlay.append(imagen);
//buttons
overlay.append(siguiente);
overlay.append(anterior);
// click
$("#imageGallery a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
overlay.show(500);
imagen.attr("src", imageLocation);
overlay.click(function(){
overlay.hide(500);
});
});