The data array in js/jquery to clicking?

$('.gotovo').click(function (event) {
 var data = $('.ship').attr('id');
 })


I need variable data were all id elements with the class ship . For example I've highlighted the 3 cells, each with its own id and I need to transfer them to the server .

The only question is how to get them...
June 3rd 19 at 21:02
1 answer
June 3rd 19 at 21:04
Solution
var array = $('.ship').map(function() { return this.id; }).toArray()
+ karma - Amelie_Crooks commented on June 3rd 19 at 21:07
,
const array = $('.ship').map(_ => this.id; ).toArray()
it will be a little shorter - Myrtis commented on June 3rd 19 at 21:10

Find more questions by tags JavaScriptjQuery