Jquery在li元素中的div的点击事件不是在移动Safari中引发的 [英] Jquery click event of a div in li element not fired in mobile Safari

查看:133
本文介绍了Jquery在li元素中的div的点击事件不是在移动Safari中引发的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修正:最后我直接生成元素,而不是由jQuery渲染。

Fixed: Finally I generate elements directly instead of being rendered by jQuery.

Updated2:看起来很清楚的真正的问题。我做了几个测试,只有一个被触发,我插入一个链接。但我不想绑定整个li元素,但在一个li中的div元素。

Updated2: It seems clear about the real issue. I did a couple of tests, only one fired that I insert a link in it. but I don't want to bind the whole li element but a div element in a li.

更新:我做了一些修改关于divs的位置,它工程在android现在,但移动Safari,甚至ul列表中的任何元素。

Updated: I did some modifications about positions of divs, it works in android now but mobile Safari even any elements in ul list.

以下工作在桌面Safari和Chrome,但不是他们的移动版本。有任何想法吗?

The following works in desktop Safari and Chrome but not their mobile versions. Any ideas?

$('#SubCategories > li .likeRibbon').live('click', function () {
   ......
});



html:



html:

<ul id="SubCategories">
      <li id="st2" >          
       <div class="likeRibbon">Like?</div>
      </li>
</ul>



css:



css:

#SubCategories .likeRibbon
{
    border-style: solid none solid none;
    border-width: 1px 0px 1px 0px;
    border-color: #565656;
    background-color: #565656;
    color: #333;
    text-shadow: 0 1px 0 #777, 0 -1px 0 black;
    line-height: 1;
    padding: 2px 0 5px 0;
    -moz-transform: rotate(-40deg);
    -ms-transform: rotate(-40deg);
    -o-transform: rotate(-40deg);
    -webkit-transform: rotate(-40deg);
    text-align: center;
    vertical-align: baseline;
    position: absolute;
    width: 100px;
    right: -35px;
    bottom: 5px;
}


推荐答案

添加一个空的onclick属性元素:

Add an empty onclick attribute to the element:

<ul id="SubCategories">
      <li id="st2" >          
       <div onclick="" class="likeRibbon">Like?</div>
      </li>
</ul>

链接到描述问题的jQuery问题

这篇关于Jquery在li元素中的div的点击事件不是在移动Safari中引发的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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