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!
you can use
$( "#nav" ).panel( "close" );
Add an extra event to make it happen. You could trigger the
click
of#menu-icon
when some menu item is clicked:Demo : http://jsfiddle.net/hungerpain/RtMNj/2/
Just in case someone will stumble upon this question where you are using
Primefaces Mobile
along withjQuery Mobile
, here is how I was able to make a workaround since the accepted solution here didn't work out for me.Basically I just put an "invisible"
a
tag that will be the one to trigger the closing of the pop up. When user clicks on the other menu item it will execute a javascriptclick()
command directed to that "invisible"a
tag.