Get all hrefs as an array in jQuery

后端 未结 8 1297
[愿得一人]
[愿得一人] 2020-12-17 20:41

My code looks like this:

  • Link 1
  • <
8条回答
  •  时光说笑
    2020-12-17 20:49

    Same code as provided by Grimace but in ES6

    const allLinks = $('#ulList a').map((i,el) => $(el).attr('href')).get();
    const allIds = $('#ulList li').map((i,el) => $(el).attr('id')).get();
    

提交回复
热议问题