Or a little bit shorter than the accepted answer:
$.map($("#foo span a"), $.text)
You can do it using .map() like this:
var myArray = $("#foo span a").map(function() {
return $(this).text();
}).get();
You can test it out here.
Additionally, the function to get the array of values with trimmed spaces:
var array = $('li').map(function(){
return $.trim($(this).text());
}).get();
use the jquery selector:
$("ul#foo span a")
Try this:
$('#foo span a').map(function() { return $(this).text(); }).get();
you can do it like this
var texts = new Array();
$('#foo > span > a').each(function()
{
texts.push( $( this ).text() );
});