Question: If I have this list...

```
<div class="class1">
    <div class="class2">
        <div class="class3">
            <span class="class4">test</span>
        </div>
    </div>
</div>
<div class="class1">
    <div class="class2">
        <div class="class3">
            <span class="class4">test</span>
        </div>
    </div>
</div>
<div class="class1">
    <div class="class2">
        <div class="class3">
            <span class="class4">test</span> <--- Add class5 here in addition to class4
        </div>
    </div>
</div>

```

How do I add class2 in the correct spots? I need it to add to the last span every time even though the number of spans will change. I have something like this, but it doesn't account for the number of items in the list.

```
jQuery(".class4)").addclass("class5");

```

Is there anyway to do a "last" class4 scenario? Any help would be appreciated.

Answer: 
Use

```
jQuery('.class4').last().addClass('class5');

```
There is a stray closing parenthesis after `.class4` in your selector:

```
jQuery(".class4").addclass("class5");

```

This still does not work because `addClass` is case sensitive[1]:

```
jQuery(".class4").addClass("class5");

```

But to target only the last `.class4` you can use the `:last` pseudo-selector[2]...

```
jQuery(".class4:last").addClass("class5");

```

... or the `.last()` jQuery method[3]:

```
jQuery(".class4").last().addClass("class5");

```

---

[1] <http://api.jquery.com/addClass/>

[2] <http://api.jquery.com/last-selector/>

[3] <http://api.jquery.com/last/>