$("#top .menu ul li").each(function(i, el) {
$(this).children('a').prepend("<span>" + (i+1) + "</span>");
});
or much better
$("#top2 .menu ul li").each(function() {
var $this = $(this);
$this.children('a').prepend("<span>" + ($this.index()+1) + "</span>");
});
check this out for the difference…
http://jsfiddle.net/reigel/aAYCt/