https://codepen.io/demi-chen/pen/RwGPgxv
JavaScript
x
13
13
1
let last = theLeftSide.lastElementChild
2
3
last.addEventListener("click",nextLevel)
4
console.log(last) =====> it does show <img>why the addEventListener not working
5
6
function nextLevel(){
7
8
event.stopPropagation();
9
numberOfFaces += 5;
10
generateFaces();
11
12
}
13
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
JavaScript
1
6
1
function nextLevel(event){
2
event.stopPropagation();
3
numberOfFaces += 5;
4
generateFaces();
5
}
6