I need help regarding jquery arrays.
var queryArr;
$(markersArray).each(function(index) {
var _locationId = index;
var _locName = markersArray[index].name;
var _markerLat = markersArray[index].marker.getLatLng().lat();
var _markerLng = markersArray[index].marker.getLatLng().lng();
var locations = {
locationId:_locationId;
locationName:_locName,
lat:_markerLat,
lng:_markerLng }
queryStr = { "locations": locations}
});
queryArr.push(location);
}
I need to reach each element using sth, like this:
alert(queryArr[0].locations.locationId);
Obviously, I will use a for loop to access each data by index.
Can anyone give me an example syntax for this. I found many examples of fixed arrays, but not dynamic content.
source
share