You are viewing a single comment's thread:

RE: Creating an Animated Hamburger Menu Icon.

Nicely done! I have always wondered how this hamburger animation is done when I come across it in websites. I already know how the JavaScript aspect is implemented but what I didn't know before now was how the "X" form of the icon is made.

In that x.classList.toggle("animate") is the .toggle() method a replacement for both .add() and .remove() methods? Coz both of them add and remove a class respectively, so I'm guessing the method you used does the work of both of them

0E-8 BEE
1 comments

I was also very curious about this, that's why I decided to try it out.

In that x.classList.toggle("animate") is the .toggle() method a replacement for both .add() and .remove() methods?

Yes! It sort of switches between those two anytime the icon is clicked and It's very useful in creating toggle buttons.

I'm really glad you found this article useful bro😊.
Thanks a lot for visiting!❤️

0E-8 BEE

Awesome 😁 I only knew about the add and remove methods but this toggle method will sure make things easier, at least I have learnt something new today. Thanks for the wonderful article

0E-8 BEE