I have a click code:
var layerMap = [];
$(document).on('click', '#TipoMapa', function(){
console.log(layerMap);
});
And I have a code that changes the layerMap variable:
$(document).on('click', '#tipo', function(){
layerMap['regional'] = layerMap['regional'] || [];
layerMap['regional'] = 'Alisson';
});
What happens is that I click the button that creates an array in layerMap
and after that, I click on the button to give console.log
on the variable layerMap
, but the content is always returning me as []
that is, empty. What can it be?