单击未在iOS上触发的事件 [英] Click events not firing on iOS

查看:60
本文介绍了单击未在iOS上触发的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含嵌套列表的列表,我想在点击它们时打开它们。它在桌面和各种浏览器上运行良好,但是当我使用iOS,iPad或iPhone时,它不想工作。

I have a list with nested lists that I want to open upon clicking them. It works fine on desktop, and across various browser, but when I use iOS, either iPad or iPhone, it does not want to work.

列表如下所示:

<ul class="lessonList">
   <li class="lessonItem" id="1"><input type="checkbox" class="scopeCheck">Default Scope
      <ul style="display:none;" class="scope1">...other content in here</ul>
   </li> 
</ul>

和代码如下:

$(document).on("click",".lessonItem",function(e){
    e.stopImmediatePropagation();
         $(this).children("ul").slideToggle();

});

我有一个stop immediateprop来停止点击激活slidetoggle的复选框但是在iOS上它不会甚至下降,直到(并且仅当)你勾选复选框。单击li本身在iOS设备中不执行任何操作。

I have a stop immediateprop to stop clicking the checkbox from activating the slidetoggle however on iOS, it will not even drop until (and only if) you check off the checkbox. clicking on the li itself does nothing in the iOS devices.

推荐答案

如果将此样式添加到 < li> 元素,它可以工作:

If you add this style to the <li> element, it works:

li { cursor: pointer; }

JSFIDDLE DEMO

这似乎是iOS事件的错误 - reference

It seems to be a bug with iOS events – reference.

这篇关于单击未在iOS上触发的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆