0

我对 Jquery 很陌生。我看到的一切看起来都很奇怪。我需要显示一个 DIV 部分作为锚标记的工具提示。我可以切换 DIV 的可见性。但是,它没有显示为工具提示,而是显示在屏幕的上角。是否可以像锚标记的工具提示一样显示 DIV 部分。

提前致谢..

<div id = "contact" class = "tooltip" style="display: none">
<asp:Label Font-Bold = "true" ID = "custLbl" runat = "server" Text = "Phone: " ></asp:Label>
<asp:Label Font-Bold = "true" ID = "custMobLbl" runat = "server" Text = "" ></asp:Label>
<br />
<asp:Label Font-Bold = "true" ID = "custLbl2" runat = "server" Text = "Mail:  " ></asp:Label>
<asp:Label Font-Bold = "true" ID = "custMailLbl" runat = "server" Text = "" ></asp:Label>
</div>

    $(function () {
        $('.contactLink').hover(function () {
            $('#contact').show();
        }, function () {
            $('#contact').hide();
        });
    });



<a  class = "contactLink" href="javascript:void();"> Click me </a>
4

1 回答 1

0

将此添加到页面

var mouseX;
var mouseY;
$(document).mousemove( function(e) {
   mouseX = e.pageX; 
   mouseY = e.pageY;
}); 

然后将您的代码更改为

$(function () {
        $('.contactLink').hover(function () {
            $('#contact').show();
            $('#DivToShow').css({'top':mouseY,'left':mouseX}).show();
        }, function () {
            $('#contact').hide();
        });
    });
于 2012-12-10T06:35:25.040 回答