I need to create an array of arrays like this:
var serviceCoors = [
[50, 40],
[50, 50],
[50, 60],
];
from elements with datas:
<div data-latitude="10" data-longitude="20" class="service-points__map"></div>
<div data-latitude="20" data-longitude="10" class="service-points__map"></div>
I`m trying this:
var test = [];
$('.service-points__map').each(function(){
var test2 = $(this).contents();
var items = [];
$.each(test2, function(i, val) {
items.push(val.data);
});
test.push(items);
});
But it doesn`t work. I have 2 arrays, but they are empty.