Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active December 16, 2023 17:54
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 braddalton/26e59188afda90b47f3947e9592447c8 to your computer and use it in GitHub Desktop.
Save braddalton/26e59188afda90b47f3947e9592447c8 to your computer and use it in GitHub Desktop.
How to add a class to submenu items when they are clicked https://wpsites.net/?p=114703
jQuery(document).ready(function($) {
// Add click event to submenu items
$('.sub-menu li').on('click', function() {
// Remove 'active' class from all submenu items
$('.sub-menu li').removeClass('active');
// Add 'active' class to the clicked submenu item
$(this).addClass('active');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment