https://codepen.io/demi-chen/pen/RwGPgxv
let last = theLeftSide.lastElementChild last.addEventListener("click",nextLevel) console.log(last) =====> it does show <img>......why the addEventListener not working function nextLevel(){ event.stopPropagation(); numberOfFaces += 5; generateFaces(); }
I try to find the lastElementChild in the first div. It does show …… after I use console.log to check. why the addEventListener not working. I click the lastElementChild smile.png face but it’s not working. if function nextLevel() is working. the left&right side should add more smile.png.
Tks!
Advertisement
Answer
its quite a simple fix really change your nextlevel to
function nextLevel(event){ event.stopPropagation(); numberOfFaces += 5; generateFaces(); }