I am trying to toggle between two classes with jQuery
$('.nav-right').toggleClass('open closed');
is toggling both classes at once because neither of those classes are applied in the markup when the page loads, and I don't want them to be. These classes apply an animation that I don't want to show when the page loads.
I'm trying to apply .open on the first click of an element and then apply .closed on the second click, and toggle between the two for every click after.
Here's a simplified pen if you want to check it out the basics in action. Everything I've googled or found on StackOverflow points to toggleClass but that doesn't seem to work in this instance.
Here is another pen with the full animations I'm trying to achieve. You can see how the nav elements fade out one by one from right to left when you click the icon - I want them to fade back in from left to right when you click it again, which I'm achieving by applying the closed class. If I have that class applied to the attribute from the get-go, the nav elements fade in when the page loads which I don't really want.