Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery菜单没有';t在移动设备上折叠/关闭_Javascript_Jquery_Mobile - Fatal编程技术网

Javascript jQuery菜单没有';t在移动设备上折叠/关闭

Javascript jQuery菜单没有';t在移动设备上折叠/关闭,javascript,jquery,mobile,Javascript,Jquery,Mobile,在PC上,移动菜单可以正常打开和关闭。但在移动设备上,菜单可以正常打开,但不能关闭。有人能看看我下面的jQuery代码并确保它是好的吗。我正在WP上使用代码 $(document).ready(function() { $(".genesis-nav-menu > li > a").on("click", function(e) { if ($(this).parent().has("ul")) { e.preventDefault(); }

在PC上,移动菜单可以正常打开和关闭。但在移动设备上,菜单可以正常打开,但不能关闭。有人能看看我下面的jQuery代码并确保它是好的吗。我正在WP上使用代码

$(document).ready(function() {
  $(".genesis-nav-menu > li > a").on("click", function(e) {
    if ($(this).parent().has("ul")) {
      e.preventDefault();
    }
    if (!$(this).hasClass("open")) {
      // hide any open menus and remove all other classes
      $(".genesis-nav-menu li ul").slideUp(350);
      $(".genesis-nav-menu li a").removeClass("open");
      // open our new menu and add the open class
      $(this).next("ul").slideDown(350);
      $(this).addClass("open");
    } else if ($(this).hasClass("open")) {
      $(this).removeClass("open");
      $(this).next("ul").slideUp(350);
    }
  });
});

有人能帮忙吗

首先,您不需要检查JQuery元素是否既没有类,也有类。你有小提琴吗?你能做一把吗?只需将您的代码添加到JS提琴中,以及您正在使用的HTML。