I have a nodeList of div and each div has an img with src, id and a dataset. When looping the nodeList with a forEach loop I store the first element of that div (hence the img) so i can then access to its id, src and dataset. I'm succeeding in getting the id and the src but not the dataset; it always returns an empty DOMStringMap {} .
How can i get this info?
each div has an img like ->
function getCards(){
let totalCards = document.querySelectorAll(".card")
totalCards.forEach(el => {
el.addEventListener("click", function(){
let thisCard = el.children[0]
let thisCardID = thisCard.id
let thisCardDataSet = thisCard.dataset
let thisCardSRC = thisCard.src
console.log(thisCard)
console.log(thisCardID)
console.log(thisCardDataSet)
console.log(thisCardSRC)
})
})
//console.log(flippedCard)
}
´´´