jquery(selector) how to select the last element from two different classes
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"&g开发者_开发知识库t;
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
First get all elements with any of the class names, then pick the last one:
$('.col1,.col2').filter(':last')
try the last() method.
$(".col1,.col2").last();
精彩评论