码迷,mamicode.com
首页 > 移动开发 > 详细

iOS中jQuery 的delegate 事件监听无效解决办法

时间:2015-10-16 19:14:12      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

前端的小朋友将原来 以下结构的代码
<a href="ssss">
<p>sssss</p>
<p>dddddd</p>
</a>

改成了


<div data-href="ssss">
<p>ssssss</p>
<p>dddddd</p>
</div>
因为涉及到一些异步加载的内容,所以使用如下代码来实现 a 标签的功能



$(document).delegate(‘[data-href]‘, ‘click‘, function () {
            if ($(this).data(‘href‘)) {
                location.href = $(this).data(‘href‘);
            }
        });

在PC浏览器上没有出现任何问题,当由iPhone 6 自带的浏览器打开的时候却直接失效了。


最终在stackoverflow上找到了解决方案,现记录如下:


On iOS there is no event bubbling without a cursor style. So in your CSS you need to add cursor: pointer; to the element.

添加CSS内容

*[data-href]{
cursor: pointer;
}





iOS中jQuery 的delegate 事件监听无效解决办法

标签:

原文地址:http://my.oschina.net/jackin/blog/518102

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!