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

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

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

4条回答
  •  隐瞒了意图╮
    2021-02-08 03:00

    Something like

    var idArray = $(".someClass").map(function(){
        return this.id
    }).get().join(',');
    

    Working demo

提交回复
热议问题