I made a script in order to create this "slideshow": <http://jsfiddle.net/LWBJG/2/>

yet I can not go back to the last slide if I hit "previous" when it is on the first slide

I tried using the last-child selector but had no success

I also tried resetting the count directly like so:

```
 if(count==1){    
    count=2;
    $(".slideshow :nth-child("+count+")").fadeIn(); 
}

```

I've been stuck with this for two days, I'm trying to understand what I'm doing wrong!

**all I what's left to do is to go to the last slide if I hit "previous" while I'm "standing" on the first slide**
['https://Stackoverflow.com/questions/23683604', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1114993/']
First you need to hide all the other `.slideshow img` elements not being shown when your page first loads. You can do that multiple ways, but here's an example:

```
$(".slideshow img:not(:nth-child(" + count + "))").hide();

```

Next, you need to hide the current showing slide when going to the previous one:

```
$(".slideshow :nth-child(" + count + ")").fadeOut();

```

Finally, you need to set the count to the number of elements in `.slideshow img` when going to the last image:

```
count = $(".slideshow img").length;

```

Here's a working example: <http://jsfiddle.net/LWBJG/22/>
You simply were not fading out in the prev loop like you were in the next button loop.

```
$(".slideshow :nth-child("+count+")").fadeOut()

```

Also, in the css, i put the following code: 

```
.slideshow > img:not(:first-child) { display:none;}

```

This makes only the first img appear as default, and then the other ones will fade in as necessary. The way you currently have it, is count is updating properly but your images are inline and are appearing behind the current image number 1.. But on your next loop click, you properly fade out the images.

Hope this helps. Here is the <http://jsfiddle.net/LWBJG/18/>