【发布时间】:2016-02-28 19:52:17
【问题描述】:
大家好,我正在使用下面的代码作为工具提示:
/*
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();
});
我试图通过调用类似这样的方法来禁用悬停:
$(gbTip).off('hover');
但这似乎不起作用,因为它仍然会在将鼠标悬停在文本上时弹出。
这里是JSFIDDLE
【问题讨论】:
标签: javascript jquery html jquery-plugins jquery-tooltip