Last active
December 16, 2023 17:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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