Get attribute values as array from selection of elements using jQuery

后端 未结 1 350
你的背包
你的背包 2020-12-16 01:33

I have the following using jQuery:

var x = $(\'.boxes > input:checked\');

From x I am trying to retrieve an array of id values and have

相关标签:
1条回答
  • 2020-12-16 02:35

    You can use jQuery.map:

    var x = $('.boxes > input:checked');
    
    var y = $.map(x, function (element){
      return element.id;
    });
    

    The y variable, will be an array containing the element ids.

    0 讨论(0)
提交回复
热议问题