li 元素中 div 的 Jquery 单击事件未在移动 Safari 中触发 [英] Jquery click event of a div in li element not fired in mobile 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.
更新:我对 div 的位置做了一些修改,它现在在 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:
<ul id="SubCategories">
<li id="st2" >
<div class="likeRibbon">Like?</div>
</li>
</ul>
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>
这篇关于li 元素中 div 的 Jquery 单击事件未在移动 Safari 中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!