admin管理员组文章数量:1394397
I have a page on iPad and am facing some issues implementing an equivalent of mouseout behavior.
So I have:
- On my page, there is a checkbox on click (or rather touch), I want to show an errorMsg
- On click/touch on anything other than the errorMsg, I want to hide the errorMsg
Below is the code I have written;
$(document).bind("touchstart",function(e){
if(e.target.id != "checkbox_err")
$("span#checkbox_err").fadeOut("slow");
});
}
$("input:checkbox").bind("touchstart",function(){
$("span#checkbox_err").fadeIn("fast");
});
Now the issue is when I click/touch on the checkbox, the errorMsg shows for a while and then it also hides it immediately (since target is not the errorMsg)
How do I fix this issue?
I have a page on iPad and am facing some issues implementing an equivalent of mouseout behavior.
So I have:
- On my page, there is a checkbox on click (or rather touch), I want to show an errorMsg
- On click/touch on anything other than the errorMsg, I want to hide the errorMsg
Below is the code I have written;
$(document).bind("touchstart",function(e){
if(e.target.id != "checkbox_err")
$("span#checkbox_err").fadeOut("slow");
});
}
$("input:checkbox").bind("touchstart",function(){
$("span#checkbox_err").fadeIn("fast");
});
Now the issue is when I click/touch on the checkbox, the errorMsg shows for a while and then it also hides it immediately (since target is not the errorMsg)
How do I fix this issue?
Share Improve this question edited Aug 10, 2011 at 19:26 joelittlejohn 11.8k2 gold badges42 silver badges54 bronze badges asked Aug 10, 2011 at 11:52 DianaDiana 4351 gold badge11 silver badges19 bronze badges4 Answers
Reset to default 1As I know there is no need to implement touch events to achieve what you want. You can use mon click event. It will be emulated by the browser of the device.
Sounds like a ghost click, have a read here http://code.google./mobile/articles/fast_buttons.html
Try this js fiddle code.It works in all major browsers and all touch devices at time..
http://jsfiddle/vecny/
Just use the change event instead of the touchstart. It should be working in a desktop browser and a touch browser too.
本文标签: iPad JavascriptjQuery touchstart issueStack Overflow
版权声明:本文标题:iPad JavascriptjQuery touchstart issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744608704a2615519.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论