How Can We Help?

< All Topics
Print

js/navigation.js

Close small menu when user clicks outside

Original:

// Close small menu when user clicks outside
document.addEventListener( 'click', function( event ) {
	var isClickInside = container.contains( event.target );

		if ( ! isClickInside ) {
			container.className = container.className.replace( ' toggled', '' );
			button.setAttribute( 'aria-expanded', 'false' );
		}
	} );

Modified

// Close small menu when user clicks outside
document.addEventListener( 'click', function( event ) {
	var isClickInside = container.contains( event.target );

		if ( ! isClickInside ) {
			container.className = container.className.replace( ' toggled', '' );
			button.setAttribute( 'aria-expanded', 'false' );
		}
	} );
	
menu.addEventListener( 'click', function( event ) {
	var onclick = menu.contains( event.target );

		if ( onclick ) {
			container.className = container.className.replace( ' toggled', '' );
			button.setAttribute( 'aria-expanded', 'false' );
		}
	} );
Previous home page template/template-home.php
Next layouts/banner/banner-layout-one.php
Table of Contents