Javascript 仅当支持触摸事件时才使用引导工具提示?

Javascript 仅当支持触摸事件时才使用引导工具提示?,javascript,twitter-bootstrap,touch,twitter-bootstrap-tooltip,Javascript,Twitter Bootstrap,Touch,Twitter Bootstrap Tooltip,我在我的网站上使用: $('body').tooltip({ selector: '.help, .searchicons li, .user-prefs, .colour' }); 唯一的问题是,当它们连接到也连接了特定触摸事件的元素时,它们在触摸设备上无法出色地工作 有没有办法在触摸元素上禁用它们 您可以检测触摸功能,然后仅在未启用触摸时创建工具提示 var is_touch_device = 'ontouchstart' in document.documentElement; i

我在我的网站上使用:

$('body').tooltip({
  selector: '.help, .searchicons li, .user-prefs, .colour'
});
唯一的问题是,当它们连接到也连接了特定触摸事件的元素时,它们在触摸设备上无法出色地工作


有没有办法在触摸元素上禁用它们

您可以检测触摸功能,然后仅在未启用触摸时创建工具提示

var is_touch_device = 'ontouchstart' in document.documentElement;

if (!is_touch_device) {
    $('body').tooltip({
        selector: '.help, .searchicons li, .user-prefs, .colour'
    });
}

您可以检测触摸功能,然后仅在未启用触摸时创建工具提示

var is_touch_device = 'ontouchstart' in document.documentElement;

if (!is_touch_device) {
    $('body').tooltip({
        selector: '.help, .searchicons li, .user-prefs, .colour'
    });
}