[英]Use Bootstrap tooltips only if touch events are supported?
I'm using Bootstrap tooltips on my site: 我在网站上使用Bootstrap工具提示 :
$('body').tooltip({
selector: '.help, .searchicons li, .user-prefs, .colour'
});
The only problem is that they don't work brilliantly on touch devices, when they are attached to elements that also have specific touch events attached. 唯一的问题是,当将它们连接到还附加了特定触摸事件的元素时,它们不能在触摸设备上出色地工作。
Is there a way that I can disable them on touch elements? 有没有办法可以在触摸元素上禁用它们?
You can detect for touch capability and then only create the tooltip if touch is not enabled. 您可以检测触摸功能,然后仅在未启用触摸的情况下创建工具提示。
var is_touch_device = 'ontouchstart' in document.documentElement;
if (!is_touch_device) {
$('body').tooltip({
selector: '.help, .searchicons li, .user-prefs, .colour'
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.