Hi all
I’m having some trouble understanding why when I refactor my event listener, it makes the nav button disappear?
Explanation on lines 16-20 of my codepen here: https://codepen.io/chunzg/pen/yLJwLoe
Hi all
I’m having some trouble understanding why when I refactor my event listener, it makes the nav button disappear?
Explanation on lines 16-20 of my codepen here: https://codepen.io/chunzg/pen/yLJwLoe
Sure, because in your event handler, if the current target of the click has the class active, then the current target of the click immediately gets the class hide.
I suspect you might want to look at what this refers to in each case. Say, console.log(this) in your event handler.
Also, if your handler function actually accepted theevent parameter, you could do things like event.target and avoid this entirely.
Thanks very much. It worked better when I went down the event.target route (or at least made more sense to me!) 
Also I changed from using className to classList.toggle which seems to work well too.