<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var test = $('li#23').attr('firstname');
alert(test)
});
</script>
<li id='1' firstname='name1' lastname='lastname1'>1</li>
<li id='2' firstname='name2' lastname='lastname2'>2</li>
<li id='3' firstname='namе3' lastname='lastname3'>3</li>
....
<li id='21' firstname='name21' lastname='lastname21'>21</li>
<li id='22' firstname='name22' lastname='lastname22'>22</li>
<li id='23' firstname='namе23' lastname='lastname23'>23</li>
<li id='24' firstname='namе24' lastname='lastname24'>24</li>