<script> (function($) { function setup_collapsible_submenus() { var $menu = $('nav > ul.nav'), top_level_link = '.menu-item-has-children > a'; $menu.find('a').each(function() { $(this).off('click'); if ($(this).is(top_level_link)) { $(this).attr('href', '#'); $(this).next('.sub-menu').addClass('hide'); } if ($(this).siblings('.sub-menu').length) { $(this).on('click', function(event) { event.stopPropagation(); $(this).next('.sub-menu').toggleClass('visible'); return false; }); } $(window).click(function() { //Hide the menus if visible $('.sub-menu').removeClass('visible'); }); }); } $(window).on('load', function () { setTimeout(function() { setup_collapsible_submenus(); }, 700); }); })(jQuery); </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