admin管理员组文章数量:1241085
I found a great answer on detecting a click outside a div from this question: How do I detect a click outside an element?, which works fantastically.
But I've noticed that it doesn't work on the iPhone when testing my site, if I tap outside the element.
Here is the code (taken directly from that answer)
$('html').click(function() {
//Hide the menus if visible
});
$('#menucontainer').click(function(event){
event.stopPropagation();
});
I found a great answer on detecting a click outside a div from this question: How do I detect a click outside an element?, which works fantastically.
But I've noticed that it doesn't work on the iPhone when testing my site, if I tap outside the element.
Here is the code (taken directly from that answer)
$('html').click(function() {
//Hide the menus if visible
});
$('#menucontainer').click(function(event){
event.stopPropagation();
});
Share
Improve this question
edited May 23, 2017 at 12:22
CommunityBot
11 silver badge
asked May 13, 2012 at 18:37
shrewdbeansshrewdbeans
12.5k24 gold badges76 silver badges118 bronze badges
1
- 3 stackoverflow./questions/3705937/… – pbond Commented May 13, 2012 at 18:40
2 Answers
Reset to default 11this worked for me :)
$('html').on('touchstart', function(e) {
$('.navbar-flyout').hide();
})
$(".navbar-flyout").on('touchstart',function(e) {
e.stopPropagation();
});
var doc = document.documentElement;
doc.addEventListener('click', function (e) { //TODO();});
The trick:
/*Add this line into only mobile css*/
body{cursor:pointer}
本文标签: JavascriptjQueryTap outside an element on an iPhoneStack Overflow
版权声明:本文标题:JavascriptjQuery - Tap outside an element on an iPhone - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740072468a2223123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论