You can use .eq()
with a negative value (-1
is last) to get n
from the end, like this:
$(".album li").eq(-2).attr("id"); // gets "li-9"
You can test it here.
You can use .eq()
with a negative value (-1
is last) to get n
from the end, like this:
$(".album li").eq(-2).attr("id"); // gets "li-9"
You can test it here.