W3 Mind Logo
Home » JQuery add/remove class on click – toggleClass()

JQuery add/remove class on click – toggleClass()

				
					<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>
				
			
				
					<ul id="menu">
  <li> <a href="#">Menu</a>
    <ul>
      <li><a href="#">Item</a> </li>
    </ul>
  </li>
  </li>
</ul>
				
			
About Author
Picture of W3Mind

W3Mind

W3Mind focuses on Blogging, Make Money Online, SEO, Business Blogging, Social Media, WordPress, Internet Tools, Web Design and Development.
Give it a Share
Facebook
Twitter
LinkedIn
You May Also Like
How to
START A
BLOG
(step by step)
Load WordPress Sites in as fast as 37ms!