I’ve been looking all over for a script that will take care of the following issues:
- Close the div when clicking outside of it.
- Close one div when the other one is clicked.
- Close the div when “More info” is clicked again.
I’m wondering why the minus icon won’t stay put when the div is active and also how to restore the plus icon in all the above scenarios.
Final version: jsFiddle
I made the
:activeselector a subclass of.triggeras @Christopher commented and fixed the behavior of the.triggerX button to toggle the class accordingly:This way it will remove the
activeclass from the other X buttons, and toggle the current one as requested.To close the boxes when you click outside the
.paneland.trigger, add this inside of your DOM Ready handler: