• I am making my first steps coding. After some courses on Internet I decided to make a child theme in WordPress and continue learning from the practice.

    I made a Child theme of the twentysixteen theme because I found his primary menu almost as I want it. I have days reading the functions.js file trying to search the function where I could change the click function on the dropdown toggle.

    The thing is that I would like to open my menu doing hover in the menu items and not in the dropdown toggle. Do you know how can I do that? Do you have some suggestion?

Viewing 1 replies (of 1 total)
  • Thread Starter gnazoa

    (@gnazoa)

    I thing that is something inside this function:

    function initMainNavigation( container ) {
    
    		// Add dropdown toggle that displays child menu items.
    		var dropdownToggle = $( '<button />', {
    			'class': 'dropdown-toggle',
    			'aria-expanded': false
    		} ).append( $( '<span />', {
    			'class': 'screen-reader-text',
    			text: screenReaderText.expand
    		} ) );
    
    		container.find( '.menu-item-has-children > a' ).after( dropdownToggle );
    
    		// Toggle buttons and submenu items with active children menu items.
    		container.find( '.current-menu-ancestor > button' ).addClass( 'toggled-on' );
    		container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
    
    		// Add menu items with submenus to aria-haspopup="true".
    		container.find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
    
    		container.find( '.dropdown-toggle' ).click( function( e ) {
    			var _this            = $( this ),
    				screenReaderSpan = _this.find( '.screen-reader-text' );
    
    			e.preventDefault();
    			_this.toggleClass( 'toggled-on' );
    			_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
    
    			// jscs:disable
    			_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
    			// jscs:enable
    			screenReaderSpan.text( screenReaderSpan.text() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
    		} );
    	}
    	initMainNavigation( $( '.main-navigation' ) );
    
    	masthead         = $( '#masthead' );
    	menuToggle       = masthead.find( '#menu-toggle' );
    	siteHeaderMenu   = masthead.find( '#site-header-menu' );
    	siteNavigation   = masthead.find( '#site-navigation' );
    	socialNavigation = masthead.find( '#social-navigation' );
Viewing 1 replies (of 1 total)
  • The topic ‘Accordion menu that opens making hover in menu Items’ is closed to new replies.