-1
I have this code, I would like to pull all selected elements and play in an array using map, what am I missing? because it does not return anything;
$('#gerar').on('click',()=>{
var selecionados = document.querySelectorAll('.select')
var res = []
selecionados.map(function(el){
res.push(el)
})
console.log(res)
})
Can I put html code? Try using normal function instead of arrow function.
– Taffarel Xavier
map
is to map, not to traverse a array, though as side effect ends up going through it. Why don’t you justres = [...selecionados]
, by cloning the "array" original?– Woss
Raul, if you take a list and go through it with a map to add everything to another list, you will only have two identical lists.
– Daniel Mendes
Thank you all for your help!
– Raul Cesar