0

Shows and hides the .box class

$('.popup').on('click', function(){
    $('.box').toggleClass('show');
});

THE CSS

.show {
    display: block;
}
Barmar
  • 741,623
  • 53
  • 500
  • 612
garfasty
  • 1
  • 1
  • You want to attach a `click` handler to the `body` and check the clicked element to determine if it's inside or outside of your popup--if outside `toggleClass('show')`. Alternatively, you could include an overlay behind your popup and listen for the click event on that. – Kevin Boucher May 19 '15 at 21:35
  • Possible duplicated question. http://stackoverflow.com/questions/152975/how-to-detect-a-click-outside-an-element http://stackoverflow.com/questions/14622606/click-anywhere-but-on-the-element-to-hide-it-w-if-statement http://stackoverflow.com/questions/714471/jquery-hide-element-when-clicked-anywhere-on-the-page – dfgd May 19 '15 at 21:35

0 Answers0