Skip to content
Advertisement

Toggle multiple divs with multiple buttons using animate.css – jQuery

I have three different buttons with three different divs that each toggle an applicable div in same place. Trying to do 2 things.

  1. Add class on .app-icon button when relative .app-div is showing so that I can add background color when active.
  2. Add an animate.css effect when toggling same .app-div open and closed so that when the div disappears it slides down, rather than just abruptly disappearing.

HTML:

JavaScript

jQuery:

JavaScript

Here’s what I have so far: https://jsfiddle.net/frshjb373/a5osx7y6/3/

Advertisement

Answer

One option is to handle an if statement checking if the icon clicked is actually active like this:

JavaScript

Updated Demo

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