我正在使用 CRM (drupal) 和移动工具提示开发网站,当我再次单击它时,我不知道如何隐藏它,这是网站 http://www.cfb.it在 servizi 部分中,工具提示在桌面上工作正常,但是当我尝试从手机(我尝试过 iPhone 和三星)访问该网站并单击它时,工具提示出现,但一旦单击它,我就无法再次隐藏它了留下来。
这是此工具提示的 jquery 代码,我不知道缺少什么。
(function($) {
$(document).ready(function() {
function tooltipInit() {
var tooltip = jQuery('.tooltip'),
target = jQuery('.icon'),
arrow = jQuery('.arrow-down'),
mobile = jQuery(window).width() < 960,
desktop = jQuery(window).width() > 960
if (mobile) {
jQuery(".overview:odd").addClass('pull-left');
target.click(function() {
target.css({
"background-position": "top"
});
jQuery(this).css({
"background-position": "bottom"
});
tooltip.removeClass('visible');
arrow.removeClass('visible');
jQuery(this).siblings('.tooltip, .arrow-down, .details').addClass('visible');
$this = $(this);
$this.parents('.icons').find('.details').removeClass('mobile-show');
$this.find('.details').addClass('mobile-show');
});
tooltip.click(function() {
jQuery(this).removeClass('visible');
jQuery(this).siblings('.arrow-down').removeClass('visible');
jQuery(this).siblings('.icon').css({
"background-position": "top"
});
});
target.unbind('mouseenter');
target.unbind('mouseleave');
}
if (desktop) {
jQuery('.pull-left').removeClass('pull-left');
target.css({
"background-position": "top"
})
tooltip.removeClass('visible');
arrow.removeClass('visible');
target.bind('mouseenter', function() {
jQuery(this).siblings('.tooltip, .arrow-down').addClass('visible');
jQuery(this).css({
"background-position": "bottom"
});
var removeTooltip = function() {
tooltip.removeClass('visible');
arrow.removeClass('visible');
};
target.bind('mouseleave', removeTooltip);
target.bind('mouseleave', function() {
jQuery(this).css({
"background-position": "top"
});
});
});
}
}
jQuery(window).on("resize", tooltipInit);
jQuery(document).on("ready", tooltipInit);
此工具提示与本网站 http://visia.themes.tf/ 中的此工具提示类似。 我将感谢您的帮助,请
最佳答案
您好,请使用下面的代码来跟踪设备是否是移动设备,然后执行您的代码
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}
关于javascript - 如何隐藏工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36480420/