gpt4 book ai didi

javascript - 仅在支持触摸事件时才使用 Bootstrap 工具提示?

转载 作者:行者123 更新时间:2023-11-29 18:21:34 25 4
gpt4 key购买 nike

我正在使用 Bootstrap tooltips在我的网站上:

$('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'
});
}

关于javascript - 仅在支持触摸事件时才使用 Bootstrap 工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18126566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com