Skip to content

Standard Navigation OnClick vs Hover

If you are using Standard Navigation which is based off Boostrap 3, you may wish to show dropdown on click vs hover. 

https://link.pixelmakers.co/s8HfGH

You can try this:

You'll need your child theme active. 

Inside the child theme style.css (folder wp-content/bellevuex-child/style.css)

.navbar .navbar-nav .dropdown:hover .dropdown-menu {
	display:none; 
} 
.navbar .navbar-nav .dropdown.open:hover .dropdown-menu {
	display:block;
}

You'll need a child theme JS script as well. (folder wp-content/bellevuex-child/js/custom_scripts.js)

(function($) {
$(document).ready(function(){
		if (Modernizr.mq('(min-width:768px)')) {
			//console.log('Adding data-toggle, data-target');
$("li.dropdown .dropdown-toggle").attr("data-toggle", "dropdown");
			$("li.dropdown .dropdown-toggle").attr("data-target", "#");         
		}
	}); 
})(jQuery);

In side your child functions file:

You may already have the // Load Child Theme Style.CSS part. If so you can ignore that part of the code block below. 

// Load Child JS Scripts 
function belevue_child_scripts() { 
	// register script location, dependencies and version     
	wp_register_script('bellevue_scripts', get_stylesheet_directory_uri() . '/js/custom_scripts.js', array('jquery','themo-js-foot','roots_main'), '1.0', true );    
	// enqueue the script  
	wp_enqueue_script('bellevue_scripts'); 
} 
add_action('wp_enqueue_scripts', 'belevue_child_scripts');  

// Load Child Theme Style.CSS function enqueue_child_theme_style() { wp_enqueue_style( ‘bellevue_css_child’, get_stylesheet_directory_uri() . ‘/style.css’, array( ‘roots_app’, ), 1.0 ); } add_action( ‘wp_enqueue_scripts’, ‘enqueue_child_theme_style’ );