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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With