2
I have a click code:
var layerMap = [];
$(document).on('click', '#TipoMapa', function(){
console.log(layerMap);
});
And I have a code that changes the variable layerMap:
$(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 the console.log
in the variable layerMap
, but the content is always returning me as []
, that is, empty. What can be?
only to confirm
#tipo
and then click on the button with id#TipoMapa
and at that point thelayerMap
still this certain void?– Neuber Oliveira
Voce is trying to access a property of an array, would not want an object instead of an array?
– BrTkCa
yes, according to JS yes, but if I give a console.log after creating the array in the click function
#tipo
it returns the array. But I click on the#tipo
he gives as empty– Alisson Acioli
can be a lot of stuff, can post a little more of your js and html or if possible reproduce your problem in jsfiddle
– HudsonPH