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/>
Using multiple `fadeIn()`s might lead to a mess. In your case, if you really want to do so, you can first `fadeOut()` all images before `fadeIn()` the desired one. This solves the problem.

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

```

`hide()` should also work.