Q:

How to get last element and to know id

I have list:
<ul id="thumbnails" class="thumbnails"> 
<li class="span12"> <li class="span12"> 
<li id="li2" class="span2"> 
<li id="li3" class="span2"> 
<li id="li4" class="span2"> 
<li id="li5" class="span2">
<li id="li6" class="span2"> 
</ul>

I need get ID for last li, i try:
num=$('li.span2').last().id;
alert(num);

But alert show 'undefined'
What is wrong?

A:

m=$('li.span2').last().id;

Correct:
 m=$('li.span2').last().attr('id');

