jquery中的工具提示鼠标移动问题 [英] Tooltip mouse move issue in jquery

查看:129
本文介绍了jquery中的工具提示鼠标移动问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在鼠标移动时使用了工具提示。其工作正常。但我无法访问的锚标签元素。鼠标光标不应该在工具提示容器内移动。我不使用任何插件的工具提示。

I used tool tip on mouse move. its working fine. but I couldn't access inside the anchor tag element. mouse cursor shouldn't be moved inside the tool tip container. I don't use any plugin for tool tip. can anyone solve the issue.

$(document).on('mousemove','.showmobileRegfieldDef',function(e){
    var left = e.pageX - $(this).parent().offset().left - 70;
    var top = e.pageY - $(this).parent().offset().top + 300;
    $('#popup-content').css( {
        top: top,
        left: left
    } ); 
});


推荐答案

您不需要检查客户端位置的工具提示。
我宁愿这样做:

you dont need to check the client position for a tooltip. I would rather do this:

addTooltip: function(element, text) {
     var tooltip = $("<span>").css({
            position: "absolute",
            display: "none",
            background: "yellow"
        }).addClass("tooltip").text(text);
     $(element).append(tooltip);
     $(element).hover(function(){
         tooltip.css("display", "block"); 
     }, function(){
         tooltip.css("display", "none"); 
     });
},

此代码会将工具提示附加到相关元素,超过它。所有你现在要做的是改变CSS到你的需要,你完成

The Code appends the Tooltip to the relevant Element and displays it if you hover over it. All you have to do now is change the CSS to your needs and you are done

这篇关于jquery中的工具提示鼠标移动问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆