Question: I am trying to make all the table cells equal to the image size, but for some reason, they won't be set to it.

<http://jsfiddle.net/gzkhW/>

HTML(shortened a bit)

```
<table>
    <tr>
        <td><img src="http://i.imgur.com/CMu2qnB.png"></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>

</table>

```

CSS

```
table {
    border:1px solid black;
}
td {width:206px;
    height:214px;
    border:1px solid black;
}

```

Answer: 
You would like to do these:

1. You can directly select using `.slide`.
2. Check the length of `nextUp` instead.

Try this, seems to be a workaround:

**JS**

```
$('.next').click(function() {
    var current = $('.slide');
    var nextUp = $('.slide').next('.hello');

    if( nextUp.length == 0 ) {
        $('div.hello:first').addClass('slide');
        $('div.hello:last').removeClass('slide');
    } 
    else {
        $(nextUp).addClass('slide');
        $(current).removeClass('slide');
    }
});

```

**[JSFIDDLE DEMO](http://jsfiddle.net/c4ZNm/15/)**
Here is working fiddle: <http://jsfiddle.net/c4ZNm/10/>

instead of 

```
$('.hello').has('.slide')

```

use 

```
$('.hello.slide')

```

When there is no more next element, nextUp wont be '', its length will be 0.
I added count to count all .hello divs - 1 for indexication. because :last-child is your "a" tag element, not .hello div, so instead :nth-child(3) selector i added .eq(count) to be more dynamic.

Best regards