Skip to content

Instantly share code, notes, and snippets.

@ahmadthedev
Created November 24, 2021 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadthedev/bacecf126ecc97000e5c9975043f779a to your computer and use it in GitHub Desktop.
Save ahmadthedev/bacecf126ecc97000e5c9975043f779a to your computer and use it in GitHub Desktop.
function subMenuSlide() {
if( jQuery('#menu-mega-menu li').hasClass('menu-item-has-children') ) {
jQuery('.menu-item-has-children').append( "<svg viewBox='0 0 140 140' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><g><path d='m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2 1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z' fill='black'/></g></svg>" );
}
jQuery('li.menu-item-has-children > svg').click(function() {
$parent = jQuery(this).parent().closest('li.menu-item-has-children');
if( !$parent.hasClass('child-menu-open') ) {
$parent.addClass('child-menu-open');
} else {
$parent.removeClass('child-menu-open');
}
});
}
window.addEventListener('load', function() {
subMenuSlide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment