Using jquery map function with arrays

jquery .map() function translates all items in an array or object to new array of items. It can be used to easily pluck out values from the DOM elements.
 var tags = $('#myTags li').map(function (i, n) {
                return $(n).find("span").text();
            }).get().join(',');

Facebook Facebook LinkedIn LinkedIn

Leave a Comment

For Gravatar icon