【发布时间】:2014-01-14 14:56:25
【问题描述】:
该网站包含带有动态内容的工具提示链接。我正在使用 jquery UI Tooltip 来显示它们。我不希望每次用户不小心将光标悬停在链接上显示工具提示。我只想显示工具提示,如果它将光标在链接上延迟几秒钟。 它应该像在 Gmail 中一样工作,当您将鼠标悬停在发件人姓名上时,您会看到有关他的信息(请参阅picture)。
我需要工具提示,用户可以与之交互,所以我使用此代码(感谢 Antonimo https://stackoverflow.com/a/15014759/274417)
$( document ).tooltip({
show: null, // show immediately
items: 'input',
hide: {
effect: "", // fadeOut
},
open: function( event, ui ) {
ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
},
close: function( event, ui ) {
ui.tooltip.hover(
function () {
$(this).stop(true).fadeTo(400, 1);
//.fadeIn("slow"); // doesn't work because of stop()
},
function () {
$(this).fadeOut("400", function(){ $(this).remove(); })
}
);
}
});
Example here(当鼠标悬停在带有工具提示的元素上时,您会看到所有这些混乱)
如何做得更好?使用超时?或者也许我应该使用 hoverIntent 插件?但是它将如何编码?
【问题讨论】:
标签: jquery html css jquery-ui tooltip