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


How i can set number of slides?

I found http://teamtreehouse.com/library/jquery-basics , i test ligth box and i like it. But... i need just 2 slide and navigate in to 10 pictures.

2 Answers

Hi Pirvan,

The forums are a great place to look for assistance, but I can tell you that it will benefit you and other forum members tremendously if you share your code along with your post, that way other members can more effectively troubleshoot the issue and help you work toward a solution. If you aren't sure how to post code, the Markdown Cheatsheet will walk you through it. This thread is also very helpful for posting on the forum: https://teamtreehouse.com/forum/howto-guide-markdown-within-posts

[Code] - JS //Problem: User when clicking on image goes to a dead end //Solution: Create an overlay with the large image - Lightbox

var interval = undefined; $(document).ready(function () { interval = setInterval(getNext, 2000); // milliseconds $('#next').on('click', getNext); $('#prev').on('click', getPrev); });

function getNext() { var $curr = $('.slideshow img:visible'), $next = ($curr.next().length) ? $curr.next() : $('.slideshow img').first();

transition($curr, $next);


function getPrev() { var $curr = $('.slideshow img:visible'), $next = ($curr.prev().length) ? $curr.prev() : $('.slideshow img').last(); transition($curr, $next); }

function transition($curr, $next) { clearInterval(interval);

$next.css('z-index', 2).fadeIn('slow', function () {
    $curr.hide().css('z-index', 0);
    $next.css('z-index', 1);


var $overlay = $('<div id="overlay"></div>'); var $image = $("<img>"); var $caption = $("<p></p>");

//An image to overlay $overlay.append($image);

//A caption to overlay $overlay.append($caption);

//Add overlay $("body").append($overlay);

//Capture the click event on a link to an image $("#imageGallery a").click(function(event){ event.preventDefault(); var imageLocation = $(this).attr("href"); //Update overlay with the image linked in the link $image.attr("src", imageLocation);

//Show the overlay. $overlay.show();

//Get child's alt attribute and set caption var captionText = $(this).children("img").attr("alt"); $caption.text(captionText); });

//When overlay is clicked $overlay.click(function(){ //Hide the overlay $overlay.hide(); });