tags:

views:

55

answers:

1

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 been unable to work out how to do this.

Something like:

var y = x[id];
// y becomes an array like ['1', '2', '3'] assuming
// that x had 3 checkboxes with id's of 1, 2, 3 etc.
+4  A: 

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.

CMS