jquery(selector) how to select the last element from two different classes

Posted by Yasir Laghari on Stack Overflow See other posts from Stack Overflow or by Yasir Laghari
Published on 2010-05-05T20:06:27Z Indexed on 2010/05/05 20:08 UTC
Read the original article Hit count: 168

Filed under:
|

for the following html

<div>
    <div class="col1" >
         I dont want to select this
    </div>
    <div class="col2">
         I dont want to select this
    </div>
    <div class="col1">
         I dont want to select this
    </div>
    <div class="col1">
         I dont want to select this
    </div>
    <div class="col2">
         I WANT to select this
    </div>
</div>

How do I select the last element with two different class names?

Tried using

$("col1:last,col2:last)

but it gives back 2 elements

tried

$("col1,col2:last")

and this gives all col1 and last of col2

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors