How to toggle between two icons without buttons using jQuery ?
Approach: The approach is to simply add an “on click” event listener to both of the icons and toggle the CSS classes of both icons using jQuery. These classes are ultimately responsible for displaying a specific icon from the icon library (Fontawesome, in this case). Here, we have used two icons,
- One with the class name of “fa-bars” (Menu icon)
- One with the class name of “fa-times” (Cross icon)
Whenever a user will click on the menu icon, its “fa-bars” class will be toggled to “fa-times”, thus the cross icon will be then displayed and vice versa is also true.
My Personal Notes arrow_drop_up
Please Login to comment...