【发布时间】:2019-07-02 06:29:18
【问题描述】:
我正在尝试编辑 WordPress 插件的内置工具提示功能。目前它在mouseleave 上立即消失。我只需要它保持一两秒钟。
我已经阅读了大量类似的问题,但我不知道在哪里为插件的现有代码添加超时延迟:
init_tooltip();
$(window).resize(init_tooltip);
target.data('is_moving', false);
var remove_tooltip = function () {
if (target.data('is_moving')) {
return;
}
tooltip.removeClass(fadin).addClass(fadeout);
var speed = 15000;
tooltip.animate({
opacity: 0
}, speed, function () {
$(this).remove();
});
if (!tiphtml && !is_swatch && !is_swatch_desc && !is_swatch_lbl_desc && !is_swatch_img && !is_swatch_img_lbl && !is_swatch_img_desc && !is_swatch_img_lbl_desc) {
target.attr('title', tip);
}
};
target
.on('tmmovetooltip', function () {
target.data('is_moving', true);
init_tooltip(1);
})
.on('mouseleave tmhidetooltip', remove_tooltip);
target.closest('label').on('mouseleave tmhidetooltip', remove_tooltip);
tooltip.on('click', remove_tooltip);
targets.closest('label').on('mouseenter tmshowtooltip', showtooltip);
targets.on('mouseenter tmshowtooltip', showtooltip);
return targets;
【问题讨论】:
-
你能告诉我们这个插件是什么吗?