Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery工具提示禁用悬停_Javascript_Jquery_Html_Jquery Plugins_Jquery Tooltip - Fatal编程技术网

Javascript jQuery工具提示禁用悬停

Javascript jQuery工具提示禁用悬停,javascript,jquery,html,jquery-plugins,jquery-tooltip,Javascript,Jquery,Html,Jquery Plugins,Jquery Tooltip,嘿,我正在使用下面的代码作为工具提示: /* Tipr 2.0.1 Copyright (c) 2015 Tipue Tipr is released under the MIT License http://www.tipue.com/tipr */ (function($) { $.fn.tipr = function(options) { var set = $.extend({ 'speed': 200, 'mode': 'bottom' },

嘿,我正在使用下面的代码作为工具提示:

/*
Tipr 2.0.1
Copyright (c) 2015 Tipue
Tipr is released under the MIT License
http://www.tipue.com/tipr
*/
(function($) {
  $.fn.tipr = function(options) {
    var set = $.extend({
      'speed': 200,
      'mode': 'bottom'
    }, options);

    return this.each(function() {
      var tipr_cont = '.tipr_container_' + set.mode;

      $(this).hover(
        function() {
          var d_m = set.mode;

          if ($(this).attr('data-mode')) {
            d_m = $(this).attr('data-mode')
            tipr_cont = '.tipr_container_' + d_m;
          }

          var out = '<div class="tipr_container_' + d_m + '"><div class="tipr_point_' + d_m + '"><div class="tipr_content">' + $(this).attr('data-tip') + '</div></div></div>';

          $(this).append(out);

          var w_t = $(tipr_cont).outerWidth();
          var w_e = $(this).width();
          var m_l = (w_e / 2) - (w_t / 2);

          $(tipr_cont).css('margin-left', m_l + 'px');
          $(this).removeAttr('title alt');
          $(tipr_cont).fadeIn(set.speed);
        },
        function() {
          $(tipr_cont).remove();
        }
      );
    });
  };
})(jQuery);

$(document).ready(function() {
     $('.tip').tipr();
});
但这似乎不起作用,因为它在文本上方悬停时仍然会弹出


这是您可以禁用悬停的

$(document).ready(function() {
    gbTip = $('.tip').tipr();
    gbTip.unbind('mouseenter mouseleave');
});
编辑:

或者,要在启用和禁用悬停效果之间切换,我们可以添加一个
no hover

$('.tip').addClass('no-hover');
有了css

.no-hover > * {
   display: none !important;
}
要再次启用悬停效果,只需删除该类

$('.tip').removeClass('no-hover');

好吧那怎么才能把它打开呢?只是gbTip.bind('mouseenter mouseleave');?如果只需要禁用悬停效果,取消绑定将是理想的选择,但要在启用和禁用之间切换,我将使用
无悬停
类代替
$('.tip')
。然后添加css规则
display:none!重要信息
,适用于tipr元件。此外,要使悬停再次起作用,只需删除
无悬停
类。哼,这会起作用,但我使用的按钮会变形为一个模块框,因为它添加了类*display:none“它不再显示模块框内的内容……理想情况下,我需要能够销毁工具提示,然后重新创建它。
$('.tip').removeClass('no-hover');