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!
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 trial

Cesar De La Vega
13,900 PointsHow would you add next and previous buttons to browse the images instead of exiting on click.
http://port-80-z0zvw4893e.treehouse-app.com
//Problem: User when clicking on image goes to a dead end
//Solution: Create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>');
var $image = $("<img>");
var $caption = $("<p></p>");
//An Image to overlay
$overlay.append($image);
//Add caption to overlay
$overlay.append($caption);
//Add overlay
$("body").append($overlay);
// A caption
//1. Capture the click event on a link to an image
$("#imageGallery a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
//1.2 Update overlay with the image linked in the link
$image.attr("src", imageLocation);
//1.1 Show the overlay
$overlay.show();
//1.3 Get child alt atribute and set caption
var captionText = $(this).children("img").attr("alt");
$caption.text(captionText);
});
//3 When overlay is clicked
$overlay.click(function(){
//3.1 Hide the overlay
$overlay.hide();
});

Seth Kroger
56,409 PointsYou can format your code with 3 backticks (```) on the line before and after.

Chyno Deluxe
16,936 Points//Fixed Code Preview
Ps. you can edit the question to view how I fixed it.

Steven Parker
225,712 Points You can't share a direct URL to your workspace, it's private just for you and only exists while you are using it.
But you can use the snapshot function in the workspace and provide the link to that.

Cesar De La Vega
13,900 PointsHere is a snapshot of my workspace. Thank you in advance! https://w.trhou.se/kxvexvsr8o
Cesar De La Vega
13,900 PointsCesar De La Vega
13,900 PointsAlso how do I format my code when asking a question ?? is there a shortcode to use?Sorry!!!