Get array of text values using selector instead of iterating?

后端 未结 7 2053
长情又很酷
长情又很酷 2020-12-14 00:18

I have some HTML like:

7条回答
  •  既然无缘
    2020-12-14 00:57

    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.

提交回复
热议问题