JQuery map items into an array

I have several elements that I just want to pull the text() out of and put into an array.

var my_items = new Array();
my_items = $(".selector").map(function() { return $(this).text(); });

Or you can do it an alternate way:

var my_items = new Array();
$(".selector").each(function() { my_items.push($(this).text()); });
Leave A Reply
All content licensed under the Creative Commons License