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
Thomas Marren
3,626 PointsUse a nav bar to cycle through multiple jQuery image galleries on one page
I'm new to jQuery and attempting to create multiple galleries on one page with the ability to click through the different galleries with a nav bar. Here are the following problems I can't figure out.
When the initial page loads I would like the thumbnails and first photo in Gallery 1 to show. Right now both gallery's thumbnails are showing.
When I switch between links, the photo in
<div class="mainPhoto">does not change. I would like it to switch to the first photo of the selected gallery. I attempted$('#'+ which).children(".initial").show();at the end of the first function but it doesn't work.
Here is the JSFiddle for a better idea of what I'm talking about. https://jsfiddle.net/TMarren/g3gdz1t7/2/
Any help would be greatly appreciated.
2 Answers
Thomas Marren
3,626 PointsJacob Mishkin
23,118 PointsFor your first question all you need to do is hide your second gallery, before your first function.
$("#two").hide();
as for the second part, Looking into that.
Thomas Marren
3,626 PointsWow. I've spent way too long on that for the answer to be so simple. Such can be programming. Thank you so much.
Jacob Mishkin
23,118 PointsTest it out and make sure it works for you. I'm working on your second question, that will take some time, but great question!
Thomas Marren
3,626 PointsI figured the second part out if you are still looking into it. If you want to finish and show me how you did it that would be great but I just wanted to tell you. Thanks for that first part!
Jacob Mishkin
23,118 PointsHow did you get the second part finished? really curious. Thanks.
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsThat's awesome! The best answers are the ones you solve yourself! thanks for posting the fiddle, It helps others when searching the forum for answers.