Close menu by clicking outside
-
Hi there.
Trying to have the menu closed by clicking outside, I added this code to functions.php:
// Close Menu
add_action( ‘wp_footer’, ‘closemenu_script’ );
function closemenu_script() {
?>
<script type=”text/javascript”>
jQuery(function($) {
$(document).ready(function() {
//close menu on lost focus
$(‘.slicknav_menu’).focusout(function(event){
$(‘.menu’).slicknav(‘close’);
});
});
});
</script>
<?php
}
Although it gets in the right code row, the menu won’t close. What’s wrong?
- The topic ‘Close menu by clicking outside’ is closed to new replies.