Get the attribute value of each element from a jQuery set, into an array

前端 未结 4 1208
Happy的楠姐
Happy的楠姐 2021-02-08 02:25

How can I get all attributes (e.g. href) of all elements matching a jQuery selector?

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-08 03:23

    More simple solution with Underscore.js

    For example: Get all links text who's parents have class someClass

    _.pluck($('.someClass').find('a'), 'text');
    

    Working fiddle

提交回复
热议问题