相关疑难解决方法(0)

$(document).click()在iPhone上无法正常工作.jQuery的

此功能在IE,Firefox和Chrome上完美运行,但在iPhone上,只有在点击时才能使用<img>.点击页面(在img上的任何地方)都不会触发事件.

$(document).ready(function () {
  $(document).click(function (e) {
    fire(e);
  });
});

function fire(e) { alert('hi'); }
Run Code Online (Sandbox Code Playgroud)

HTML部分非常基础,不应该是一个问题.

有任何想法吗?

javascript iphone jquery click onclick

110
推荐指数
4
解决办法
15万
查看次数

在iPad上没有调用jQuery单击处理程序

我有一个使用jQuery和大量动态生成内容的项目.click左上角元素上有一个处理程序 - "主动"得分 - 它在桌面Safari上工作正常但在Mobile Safari上根本没有调用; 灰色覆盖层永远不会出现,也不会采取任何措施.与点击区域(右侧172)的点击处理程序和状态(底部的"添加状态效果";确认;它出现在肖像上)的情况相同:所有工作都在桌面上但不是移动Safari.

我已将代码缩减为以下内容:

<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script>
      $(function() {
        $('#dynamic').click(function() {alert("works")});
        $('#dynamic-with-onclick').click(function() {alert("works")});
        $('#dynamic-with-dynamic-onclick').click(function() {alert("works")}).attr('onclick', '');
      })
    </script>
  </head>
  <body>
    <ul>
      <li id='static' onclick='alert("works")'>If there's an onclick it's called</li>
      <li id='dynamic'>And if there's no onclick the iPad won't see other click events</li>
      <li id='dynamic-with-onclick' onclick=''>But if there is one all events are called</li>
      <li id='dynamic-with-dynamic-onclick'>And if we add one everything works</li>
    </ul>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

更新

现在看起来比我10个月前最初提出这个问题要简单得多; 使用现代Mobile Safari,所有点击处理程序都会正常注册.所以,出去,只是使用$(...).click(function() {})!

jquery mobile-safari ipad

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

jquery ×2

click ×1

ipad ×1

iphone ×1

javascript ×1

mobile-safari ×1

onclick ×1