简体   繁体   English

在手机/平板电脑上单击某项时,使菜单消失

[英]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. 这是网站链接: http : //rimowaedition.com/在平板电脑或移动设备上,菜单浓缩为一个按钮。 To chose anything on the menu 1. i have to click the button and it brings a drop down list. 要选择菜单上的任何内容1.我必须单击按钮,它会带来一个下拉列表。 2. Click on the page i want to go to. 2.单击我要转到的页面。 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. 3.单击菜单按钮关闭下拉列表,否则它将占用整个屏幕,而我看不到背面的页面。

Here is a screenshot of how it is: http://imgur.com/aV7RHwb 这是它的屏幕截图: 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 所以...如果您使用的是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. 这也可以在普通javascript中完成。 Just search up click events in javascript. 只需在javascript中搜索点击事件即可。

Use JavaScript Use JavaScript on the click event of any of the 使用JavaScript在任何以下事件的click事件上使用JavaScript

> <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 在菜单中隐藏meUse JavaScript,对任何

> <a href>'s

in the menu to hide the menu. 在菜单中隐藏菜单。 nu.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM