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 trialNouh Ahmed
7,085 PointsJQuery Basics- Plan
My code and the teachers code is same. But the image is not added to the overlay. This is my code
//Problem: User when clicking on image goes to a dead en //1. Solution: Create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>'); // add an overla $image = $("<image>"); $overlay.append($image); // add an image // a caption $("body").append($overlay); //1.1 We should capture a click on a link to an image $("#imageGallery a").click(function (event) { event.preventDefault(); var imageLocation = $(this).attr("href"); //console.log(imageLocation); //1.2 update overlay with the image linked to the link $image.attr("src", imageLocation); //show the overlay $overlay.show(); //1.3 get child's attribute and set caption. });
1 Answer
Steven Parker
231,269 PointsYour code differs from the video. The HTML tag for an image is "<img>".
But in your code above, you create the image tag using "<image>", which is not a standard HTML tag that a browser would recognize.