Alv*_*oli 19
我正在寻找相同的东西,并找到了这个优雅的解决方案:
http://osvaldas.info/blog/elegant-css-and-jquery-tooltip-responsive-mobile-friendly
奖金是指在手机上它会在你触摸它时"粘住"并在你再次触摸时消失.
您可以使用jQuery UI 工具提示并确保工具提示在页面中的任何触摸时关闭,如下所示:
initTooltip = function ($el) {
var closeTooltipOnClick = function (e) {
// This code if for touch devices only.
// We want to tooltip to close, when we touch
// anywhere on the page, except if we touch on
// the link itself.
if ($(e.target).closest($el).size()) {
// We just clicked on the link, so let's
// not close the tooltip.
return;
}
$('body').off('touchend', closeTooltipOnClick);
$el.tooltip('close');
};
$el.tooltip({
open: function () {
if (!Modernizr.touchevents) {
return;
}
// We make sure that the tootlip closes on
// touch devices if there is a touch event anywhere.
$('body').on('touchend', closeTooltipOnClick);
}
});
};
Run Code Online (Sandbox Code Playgroud)