当我们在平板电脑上单击外部时,如何关闭bootstrap 3下拉菜单? [英] How to close bootstrap 3 dropdown when we click outside on a tablet?
本文介绍了当我们在平板电脑上单击外部时,如何关闭bootstrap 3下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在这样做,并且在桌子上工作正常:
I am doing this and it works fine on the desk:
$(document).on("click", function(){
$(".dropdown-toggle").removeClass("open");
});
但是在iPad上,它无法正常工作,并且我的下拉菜单保持打开状态
But on the iPad that it isn't working and my dropdown remains open
推荐答案
您应该在触摸设备上使用touchstart
和touchend
事件:
You should use the touchstart
and touchend
events with touch devices:
$(document).on("click touchend", function(){
$(".dropdown-toggle").removeClass("open");
});
这篇关于当我们在平板电脑上单击外部时,如何关闭bootstrap 3下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文