based on this demo: http://webdesignerwall.com/demo/mobile-nav/ this is my code.
<script type="text/javascript">
    jQuery(document).ready(function($){
        /* prepend menu icon */
        $('#nav-wrap').prepend('<div id="menu-icon"><img id="logo" src="<?php echo site_url(); ?>/wp-content/themes/blue-and-grey/images/mobileimages/hme_btn.png" /></div>');
        /* toggle nav */
        $("#menu-icon").on("click", function(){
            $("#nav").slideToggle();
            $(this).toggleClass("active");
        });
    });
    </script>
what i need is the menu to "close" after i click a menu item because it's a single page website, and i don't want it to stay opened after i clicked. how do i do that?
thank you so much!
Add an extra event to make it happen. You could trigger the click of #menu-icon when some menu item is clicked:
 $("#nav").on("click", "li", function () {
       $("#menu-icon").click();
       //or $("#nav").slideToggle();
 });
Demo : http://jsfiddle.net/hungerpain/RtMNj/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With