<script>
jQuery(document).ready(function($) {
// Handle clicks on main menu items
$("a.premium-menu-link").click(function(e) {
var submenu = $(this).siblings('.premium-sub-menu');
if (submenu.length) {
// Toggle the submenu visibility with a delay
setTimeout(function() {
submenu.toggleClass('active-menu');
// Add a class to the clicked parent menu link
$(this).addClass('parent-menu-link');
// Remove submenu-link class from all submenu items
$(".premium-sub-menu a.premium-menu-link").removeClass('submenu-link');
// Set inline styles on the parent <ul>
var parentUl = $(this).closest('ul');
parentUl.css({
'visibility': 'visible',
'overflow': 'visible',
'opacity': 1,
'height': 'auto'
});
// Set opacity to 1 on the <li> elements of the same <ul>
parentUl.find('li').css('opacity', 1);
}.bind(this), 150); // Adjust the delay in milliseconds
// Close other open submenus (optional)
$(".premium-sub-menu").not(submenu).removeClass('active-menu');
// Prevent redirection for non-leaf items
e.preventDefault();
}
});
// Handle clicks on submenu items
$(".premium-sub-menu a.premium-menu-link").click(function(e) {
// Add a class to the submenu link
$(this).addClass('submenu-link');
// Set inline styles on the parent <ul>
var parentUl = $(this).closest('ul');
parentUl.css({
'visibility': 'visible',
'overflow': 'visible',
'opacity': 1,
'height': 'auto'
});
// Set opacity to 1 on the <li> elements of the same <ul>
parentUl.find('li').css('opacity', 1);
});
});
</script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter