Navigation button question

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:

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 and avoid this entirely.

1 Like

Thanks very much. It worked better when I went down the route (or at least made more sense to me!) :pray:
Also I changed from using className to classList.toggle which seems to work well too.

1 Like