Reputation: 57
I'd like to select last div which id starts with "level":
var div = $('div[id^="level"]:last');
But as well I'd like to select the last and visible one. How could I perform that? Following doesn't work:
$('div[id^="level"]:last:visible');
I tried couple different combinations but none worked.
Upvotes: 2
Views: 895
Reputation: 207891
Try switching your :last
and :visible
that was you first filter all the elements by their visibility, and then filter for the last one.
$('div[id^="level"]:visible:last');
Upvotes: 2
Reputation: 8058
Maybe something like this?
var div = $('div[id^="level"]:last').filter(":visible");
Upvotes: 2