Reputation: 1623
I am try to select the last element of a child that does not have a certain class. I have setup a js fiddle
.
<aside class="col2">
<div class="infobox teal"></div>
<div class="infobox mediumbrown"></div>
<div class="quotebox"></div>
<div class="quotebox"></div>
</aside>
I have tried:
$("aside.col2 div:last").not(".quotebox").addClass("last-round");
Any thoughts?
Upvotes: 0
Views: 2224
Reputation: 31131
$("aside.col2 :not(.quotebox)").last().addClass("last-round");
Select all of the ones that don't have the class, THEN get the last one.
Upvotes: 0
Reputation: 78630
You have to do the not
prior to the last
:
$("aside.col2 div:not('.quotebox'):last")
Upvotes: 17