简体   繁体   English

单击功能在移动设备中无法正常工作

[英]Click Functionality doesn't work properly in mobile devices

We are facing an issue in our shopify website in mobile devices. 我们在移动设备上的shopify网站中面临一个问题。 On clicking a category, it opens and child menu items dropped down. 单击类别后,它将打开,并且子菜单项将下拉。 But it doesn't get closed on clicking back. 但是单击返回并不会关闭。 Only it gets closed, when we click on another category menu. 当我们单击另一个类别菜单时,只有它关闭。

Could anyone help here. 任何人都可以在这里帮忙。 Thanks in advance. 提前致谢。

Its better to show code you are trying. 最好显示您尝试的代码。

Main problem is OnClick Event does not register on mobile devices that is because you don't click on anything you generally tap on menu. 主要问题是OnClick事件未在移动设备上注册,这是因为您没有单击通常在菜单上单击的任何内容。 So it will be better if you add mobile event along with it. 因此,如果您将移动事件与之一起添加,那就更好了。 like you can use touchstart event as give in code below 就像您可以使用touchstart事件,如下面的代码所示

$(document).ready(function() { 
    $('ul li').on('click touchstart', function() {

    // Show Menu Item

    });
});

Another Alternative Option 另一种选择

you can also detect touch devices and manipulate things - 您还可以检测触摸设备并进行操作-

$(document).ready(function() {      
    /* Detect Mobile Device As Below */
    if(is_touch_device()) {  
        // Code Here to handle for Mobile
    }
});

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

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