2014-11-20 33 views
-1

我正在使用jquery API来显示工具提示。我想将鼠标悬停在表格图像上的图形旁边的工具提示放置在图像附近,并且当我将鼠标悬停在图像上时,以前的工具提示仍然是 ,我可以在鼠标从图像移开后立即淡出工具提示。请找到小提琴:http://jsfiddle.net/0w9yo8x6/4/ 下面的代码片段:鼠标移出后立即提示定位和隐藏工具提示

$(function() { 
    $(document).tooltip({ 
     content: function() { 
      return $(this).prop('title'); 
     }, 
     show: null, 
     close: function (event, ui) { 
      ui.tooltip.hover(

      function() { 
       $(this).stop(true).fadeTo(400, 1); 
      }, 

      function() { 
       $(this).fadeOut("400", function() { 
        $(this).remove(); 
       }) 
      }); 
     } 
    }); 
}); 

$(function() { 
    $('.one').attr('title', $('.tooltipTable').remove().html()); 
    $(document).tooltip(); 
}); 
$(function() { 
     $('.one').attr('title', $('.tooltipTable').remove().html()); 
     $(document).tooltip(); 
    }); 
+0

也许看到:http://stackoverflow.com/questions/13057606/jquery-ui-tooltip-manual-open-close – 2014-11-20 21:04:32

回答

1

,而不是实现自己的“关闭”功能,您在创建提示时,简单地可以设置showhide属性false

看看文档show/hide

$(document).tooltip({ 
    content: function() { 
     return $(this).prop('title'); 
    }, 
    show: false, 
    hide: false 
}); 
+0

我必须执行工具提示数据上的一些事件,比如我应该能够点击数据并执行一些显示在工具提示上的事件。你可以在http://jsfiddle.net/0w9yo8x6/4/看到这个功能。您建议的代码仅在工具提示仅用于查看目的而没有在工具提示内显示的数据内执行任何事件时起作用。 @lloiser。 – user4199704 2014-11-21 15:51:53

+0

尝试更改工具提示的位置,以便它在图像的右侧打开(如http://jsfiddle.net/0w9yo8x6/5/) 请参阅http://api.jqueryui.com/tooltip/#option -位置 – lloiser 2014-11-22 10:38:22