title: jQuery - How to remove class if clicking outside of div or open/close button
body: <p>I'm fairly new to JS and I can't quite figure out how to get this to work. Any help is very much appreciated! So I have a hamburger button that, when clicked, simultaneously toggles the animation of a slide-in panel and hamburger animation by adding a class to the panel and button. I have successfully added a click event to close the panel if user clicks anywhere outside of the panel but I can't get the hamburger button to remove the added classes as well. I'd like the user to have both options (click button or click outside of panel). </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;ul class="nav nav--right"&gt;
    &lt;li class="v-button--slide-right" id="toggle-menu"&gt;
      &lt;button class="mpp-menu-icon mpp-menu-icon--cross toggle-menu"&gt;
        &lt;span class="toggle"&gt;&lt;/span&gt;
        &lt;span class="menu"&gt;menu&lt;/span&gt;
      &lt;/button&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;nav id="menu--slide-right" class="nav menu--slide-right"&gt;
    &lt;ul class="main-menu"&gt;
      &lt;li&gt;&lt;a href="/home"&gt;Home&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/about"&gt;About&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;&lt;!-- end slide menu --&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>jQuery(document).ready(function($) {
  
      var openSidebar = function() {
          $('.menu--slide-right').addClass('is-active');
          $('.toggle-menu').addClass('is-active');
          $('#toggle-menu').addClass('toggle-close');
      }
      var closeSidebar = function() {
          $('.menu--slide-right').removeClass('is-active');
          $('.toggle-menu').removeClass('is-active');
          $('#toggle-menu').removeClass('toggle-close');
      }
  
  
      $('.toggle-menu').click(function(event) {
          event.stopPropagation();
          openSidebar();
      });
  
      $(document).click(function(event) {
          if (!$(event.target).closest('.menu--slide-right').length) {
              closeSidebar();
          }
      });
  });
  </code></pre>
  
  <p><a href="https://jsfiddle.net/5ssccz2a/" rel="nofollow">And here's a JSFIDDLE to demo what I have so far</a></p>