如何隐藏工具提示?

时间:2016-04-07 15:16:18

标签: javascript jquery drupal-7 tooltip jquery-tooltip

我在网站上使用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/ 我将非常感谢您的帮助

1 个答案:

答案 0 :(得分:1)

您好请使用以下代码跟踪devide是否为移动设备,然后执行您的代码

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 // some code..
}