I want to click menu toggle then open menu - javascript

codepen.io/raihan-rony/pen/pOwQar
Check my code on CodePen
When I click svg menu blue area, My menu opens and closes itself, but I need to click menu toggle then it open and close.

Related

Close menu on mobile devices with anchor link

I have been reading in this community and testing codes but I can not close the menu.
I have created a simple JSFiddle to understand it. I would like to close it using jQuery. The problem is only in mobile view. In this example, the user clicks on the "MORE" menu and a "NEWS" item appears. "NEWS" is an anchor link and when the user clicks there, the menu is still open. This is the problem. How can I close the menu?
I have tried everything.
jQuery(".item-131").css( 'pointer-events', 'none' );
jQuery(".item-131").attr('onmouseover','');
jQuery(".item-131").off('mouseenter mouseleave');
jQuery(".item-131").unbind("mouseenter mouseleave");
But I can not close the menu.
See my JSFiddle: https://jsfiddle.net/karmany/gc0ku8on/
If you could show your cursor on mobile you'd see that when you click menu the cursor is still above the menu button until you actually tap off it — now you could have an on click event that closes the menu when it's clicked?

Make navbar collapse/close on click

i have trouble making the navbar on mobile devices collapse with my website. The problem only concerns the mobile version of the website.
When I click on a menu button, the site scrolls to the correct point, but the navbar remains opened, which is annoying. I tried to give the UL LI elements the same class like the "back" button in the navbar, which can collapse the navbar, but this does not work :/..
Could anyone show me how I can make the navigation bar close whenever a menu item is clicked?
This is the website:
Thanks a lot
You could solve it with jQuery, by just triggering the action of clicking the menu icon, like this:
jQuery('.rd-navbar-nav li').click(function() {
jQuery('.rd-navbar-toggle').trigger('click');
});
This way, when you click an element in the menu, it emulates clicking the hamburger menu icon too.
You can use Jquery if you'd like, but I just use JavaScript on my sites. You can take a look on how to make a collapsible navbar menu with JavaScript here. If you want to close the menu bar whenever a menu item is clicked, just set a close() function in the onClick() attributes if the menu is active and open. The close() function will be the function in which you hide the menu once again.
EDIT: You must define the close() function with in your JavaScript and set it to hide the menu items though.

mmenu - how to switch off auto open on page load

Every time I load a page using mmenu the menu automaticaly appears after a second. How do I switch this off? I want the menu to appear ONLY after clicking on the menu button.
This is a link to the plugin: http://mmenu.frebsite.nl/
Thanks & regards
If the URL contains a hash that points to the menu, the menu will open. This is so the menu will open even if the user clicks the button before the menu was created. If you remove the hash from the URL, the menu will not open on pageload.

Make menu go away when an item is clicked on mobile/tablet

I have a pretty specific problem which i am hoping someone can guide me in the right direction with.
Here is the website link : http://rimowaedition.com/
When on a tablet or mobile device the menu is condensed into a button. To chose anything on the menu
1. i have to click the button and it brings a drop down list.
2. Click on the page i want to go to.
3. click the menu button to close the drop down list or else it takes up the whole screen and i cannot see the page in the back.
Here is a screenshot of how it is: http://imgur.com/aV7RHwb
Is there any way to make it so that when i click an item in the drop down it automatically closes the menu and goes to that page.
Any guidlines or clues as to how i would go about doing this would be much appreciated since as of now i am pulling my hair out .
You can set a click event on any item in the menu lists that you click.
So...
If you're using jQuery
$('list-item').click(function() {
//Remove the class that causes the menu to be open
//Perform any actions that you need after the button is clicked
//such as loading another page
});
This can also be done in vanilla javascript. Just search up click events in javascript.
Use JavaScript Use JavaScript on the click event of any of the
> <a href>'s
in the menu to hide the menu.
on the click event of any of the
> <a href>'s
in the menu to hide the meUse JavaScript on the click event of any of the
> <a href>'s
in the menu to hide the menu.
nu.

Foundation 5 The expanded topbar menu remains visible when clicking the browser "back" button

I just looked at the Foundation site, and this appears to be the default behavior. It seems strange. Clicking the browser back button should load the previous page but, it opens menu dropdown.
How can I hide that menu drop down? And it should show the previous page.
Thanks

Categories