对于您的第一个问题,您可以使用eq基于 0 的 :
$('ul li', '#thediv').eq(2).addClass('whatever'); // add class to 3rd item
对于第二个问题,您可以使用each遍历所有列表项。回调函数传递一个包含集合中当前元素索引的参数:
$('ul li', '#thediv').each(function(i) {
$(this).text(i); // update each list item with its index, 0 based.
});