2012-12-10 46 views
0

我對Jquery很新。我看到的一切都看起來很奇怪..我需要顯示一個DIV節作爲Anchor Tag的工具提示。我可以切換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> 
+0

一個DIV是一個屏幕元素,無論你在哪裏展示,它都會改變你的頁面。您可能希望查看更改div的z-index,然後將其放置在錨標記旁邊,然後執行顯示/隱藏。 – ryadavilli

+0

將js包裝成腳本標記 –

回答

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(); 
     }); 
    });