[英]Dropdown doesn't disappear on iPad
I have a simple dropdown button which shows content when user clicks or taps (on touch screens) the button. 我有一个简单的下拉按钮,当用户单击或点击(在触摸屏上)按钮时,它会显示内容。 It works great but on some mobile devices (especially iPad and devices with Windows Mobile), the dropdown doesn't disappear when user touch the screen outside the dropdown.
它可以正常工作,但在某些移动设备(尤其是iPad和装有Windows Mobile的设备)上,当用户触摸下拉列表外的屏幕时,下拉列表不会消失。
Here's HTML: 这是HTML:
<div class="dropdown">
<div class="dropdown-toggle">Click Me</div>
<div class="dropdown-menu">Example contnt of the dropdown</div>
</div>
Here's JavaScript: 这是JavaScript:
$(document).on('mouseenter', '.dropdown', function() {
$(this).children('.dropdown-menu').show();
}).on('mouseleave', '.dropdown', function() {
$(this).children('.dropdown-menu').hide();
});
You can add the touchstart
event to the following 您可以将
touchstart
事件添加到以下内容中
$(document).on('mouseenter touchstart', '.dropdown', function() {
And likewise, the touchend
event on the mouseout 同样,mouseout上的
touchend
事件
}).on('mouseleave touchend', '.dropdown', function() {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.