Rufusmedia
1/9/2015 - 12:43 AM

jQuery menu toggle

jQuery menu toggle

jQuery(function() {
	// toggle the open class to the parent menu when you click.
	// this opens the sub menu with CSS
	// stop propagation so that you can close the menu when 
	// you click on the page outside the menu
  jQuery('.menu-item-has-children').on('click', function(e){
    e.stopPropagation();
		jQuery(this).toggleClass('open');
    });
    // remove the open class when you click outside the menu
    jQuery(document).on("click", function() {
		if(jQuery('.open')){
			jQuery('.open').removeClass('open');
		}
	});
});