Issue
My problem is when i click tap only first tap is working when i click another tap is show error
Uncaught TypeError: Cannot read properties of undefined (reading 'classList')
This my code https://codepen.io/rodkeaw-rk/pen/NWavQPY
Solution
If you look at your html you can see you've got multiple elements with an id of 'panals'
So when you call
let panals = document.getElementById('panals')
It will return the first element with an id of 'panals', regardless of which panel you click on. This will be the 'John' panel. So when you click on 'Anna' and try and do
panals.getElementsByClassName('Anna')[0]
it will return undefined because panals will always be the John panel.
Answered By - matt helliwell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.