admin管理员组文章数量:1277875
i tried different ways.
I need onclick for a div with jquery in my mobile site. On clicking on the div it will send an ajax call.
$(document).ready(function() {
... ......
$('body').on('click','.selectableCard', function() {
$.ajax({
url : URL}).done(
function(data) { ..... .... });
});
...
....
});
This is working fine in desktop browsers and in android emulator. But not working in iPode4.
Div
<div class="resultsMainContainer selectableCard ">
style
.selectableCard {
pointer-events: auto !important;
}
.resultsMainContainer {
background-color: #FFFFFF;
border: 1px solid #D6D6D6;
box-shadow: 3px 3px 5px 1px #CCCCCC;
display: inline-block;
margin-bottom: 15px;
padding-bottom: 10px;
padding-left: 10px;
padding-top: 10px;
width: 98%;
}
I tried as:
$('.selectableCard').click(
function(){....
But it's not working in desktop itself. !
Any idea would be appreciated :)
Here is an updated jsFiddle: /
Will work fine in desktop , but not working in iPod
i tried different ways.
I need onclick for a div with jquery in my mobile site. On clicking on the div it will send an ajax call.
$(document).ready(function() {
... ......
$('body').on('click','.selectableCard', function() {
$.ajax({
url : URL}).done(
function(data) { ..... .... });
});
...
....
});
This is working fine in desktop browsers and in android emulator. But not working in iPode4.
Div
<div class="resultsMainContainer selectableCard ">
style
.selectableCard {
pointer-events: auto !important;
}
.resultsMainContainer {
background-color: #FFFFFF;
border: 1px solid #D6D6D6;
box-shadow: 3px 3px 5px 1px #CCCCCC;
display: inline-block;
margin-bottom: 15px;
padding-bottom: 10px;
padding-left: 10px;
padding-top: 10px;
width: 98%;
}
I tried as:
$('.selectableCard').click(
function(){....
But it's not working in desktop itself. !
Any idea would be appreciated :)
Here is an updated jsFiddle: http://jsfiddle/smilyface/y7DX5/1/
Will work fine in desktop , but not working in iPod
Share Improve this question edited Nov 14, 2013 at 14:07 smilyface asked Nov 12, 2013 at 12:40 smilyfacesmilyface 5,52111 gold badges44 silver badges60 bronze badges 17- not sure that the $(document).ready( works on mobiles – Liam Sorsby Commented Nov 12, 2013 at 12:42
- document ready works fine in mobile. Because i used it in another pages in the same application. – smilyface Commented Nov 12, 2013 at 12:43
- should you have $('body') in quotes? shouldn't it be $(body) – Liam Sorsby Commented Nov 12, 2013 at 12:44
- Liam, it has a single quote. 'body' – smilyface Commented Nov 12, 2013 at 12:46
- ah my mistake just looked it up my self. What version of jquery are you using and are you using jquery mobile for your mobile sites or just jquery? – Liam Sorsby Commented Nov 12, 2013 at 12:47
2 Answers
Reset to default 11On iphone you must use touchevent
for exemple:
$('.selectableCard').on('click touchstart',function(){
//your code
});
Got it working.
I just put the entire onclick function (onclick selectableCard) inside the ajax. So that it will run each time when the ajax loads. Thus it can get the class/div specified inside the jQuery.
$.ajax({
url : URL
}).done(
function(data) {
container.html(data); //innerHTML part
$('.selectableCard').click(function(){..call div came through above innerHTML..});
});
本文标签: javascriptjquerydiv onclicknot working in iPhoneStack Overflow
版权声明:本文标题:javascript - jquery - div onclick - not working in iPhone - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741259243a2367287.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论