JQuery add/remove class on click – toggleClass()

jQuery Function

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#menu li').on('click', function () {
            $(this).toggleClass('open');
    });
});
</script>

HTML

<ul id="menu">
  <li> <a href="#">Menu</a>
    <ul>
      <li>>a href="#">Item</a> </li>
    </ul>
  </li>
  </li>
</ul>