在图像附近显示鼠标上的工具提示

show tooltip onmouse over near the image

本文关键字:工具提示 鼠标 显示 图像      更新时间:2023-09-26

我想在将鼠标悬停在表格中的图像上时显示工具提示。请找到样品小提琴 http://jsfiddle.net/FpBu4/42/我想在鼠标悬停时在图像的右上角显示工具提示。下面是示例脚本:

$('.one').hover(function(ev){
    $('.tooltipSample').stop(true,true).fadeIn(); 
},function(ev){
    $('.tooltipSample').stop(true,true).fadeOut();
}).mousemove(function(ev){
    $('.tooltipSample').css({left:ev.layerX+10,top:ev.layerY+10});
});

请建议如何在将鼠标悬停在图像上时在图像附近显示工具提示。谢谢。

position:absolute;添加到tooltipSample并使用pageXpageY而不是layerXlayerY

小提琴

请注意

,我还没有测试过这个。但是,在我最近参与的一个项目中,我不得不在控件附近动态添加新的div。我所做的是将新的div 添加到控件的父级。

也许你可以做这样的事情:

$('.one').parent().hover(function(ev){...});

只是一个想法,也许其他人可能有更好的解决方案