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 trialGarrett Reid
Front End Web Development Techdegree Student 17,532 PointsNext/Previous buttons for Photo Gallery?
Hello everyone!
First off, I have a link to a jsfiddle with the code just to keep this post as short as possible. Here it is: https://jsfiddle.net/v5wmq45s/
The gist is, you click on the scaled-down image, and it appears in a lightbox with the actual sized image along with a title. There are two arrows on either side, and I need help getting those to show the next/previous image and title element.
I'm sorry if my description is vague and terrible... maybe the fiddle will help clear it up. If you need any further information, please let me know! Thank you for the help. It is greatly appreciated!!
2 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsProbably the simplest way would be to trigger a click
event on the img
previous to or next to the one in a li
with the class selected
(which you're adding, but not removing from others in your code).
You'll need to handle the edge cases where the first item is selected (either hide the previous arrow or make it fire the click
event on the last item to 'wrap' the gallery slider) or the last item.
You can either use .click()
with no parameters to trigger on the selected element, or .trigger('click')
.
Steven Parker
231,261 PointsI tried your link, but only saw empty squares with captions (no images). And clicking on them did not do anything.
And I did hit the "run" button in the menu.