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 trial
Erin Brunken
8,490 PointsDirectional arrows in lightbox not working...
I am coding a lightbox with next and previous directional arrows for the user to move to the next or previous image. I have appended the arrows to the lightbox and coded it so that when you click on either arrow it takes you to the correct image, however it only works once each way. Could anyone help me to fix it so that it will cycle through all the images if either arrow is clicked. I also need to update the alt text when the next/prev image is shown as well.
Here is the code: https://github.com/Erinbrunken/project-four-lightbox
1 Answer
Seth Kroger
56,416 PointsI see that you store $selectedImage, which you use to get the next and previous images. However I don't see you set it to the new image, so the next and previous image will always be in relative to the original image, not the one currently displayed.