Skip to content
Advertisement

How to change the collapse menu icon with JS?

I have a main menu (collapse) that uses Bootstrap 3.3.7 and Font Awesome 5.0.1

What I am looking for :

  • When the menu is closed, a “plus” icon is displayed.

  • When the menu is open, a “minus” icon is displayed.

The “plus” icon is displayed on the menu but does not change.

I think there is a problem with my JS code.

JavaScript

Here is my JS code. Something is wrong with it.

JavaScript

Screenshot

enter image description here

Advertisement

Answer

You have not used the right bootstrap events for dropdown. Try this one.

JavaScript

REf: https://getbootstrap.com/docs/3.3/javascript/#dropdowns-events

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement