2012-03-06 92 views
0

有沒有一個工具提示,而不是使標題出現在它,我可以使信息從一個div出現... 我有一個圖像,我想要一個可能在它下面的一個看不見的div ,所以當用戶懸停在圖像上的div出現與名稱地址面書就像它等?jQuery的工具提示讓div出現

<img width="448" height="300" src="/Content/uploadedImg/1.png                                                               " onerror="this.src='/Content/img/redboxlrg.png';"> 

回答

0

你可以嘗試像 -

<img width="448" height="300" src="/Content/uploadedImg/1.png" id="hoverimage" /> 
<div id="showdiv" style="display:none;">Hidden initially, because of 'display:none;'</div> 
<script> 
    $("#hoverimage").hover(function(){ 
    //this happens when you first 'hover' over the image with id = 'hoverimage' 
    $("#showdiv").stop().fadeIn(500); //stop() is important, it prevents a 'queue' from building 
    //the .fadeIn(n) function will fade an element in over n milliseconds 
    }, function(){ 
    //this happens when the mouse moves out/hover ends 
    $("#showdiv").stop().fadeOut(500); 
    //similarly, the fadeOut(n) function fades an element out over n ms 
    } 
</script> 

注意,對於這一點,你還需要包括jQuery庫,以利用jQuery(或$)功能。

http://www.worthapost.com/articles/how-include-jquery-your-website-google更多關於該

+0

我已經jQuery的包括但不工作,我需要在div上的圖像的頂部會顯示不低於其 – Beginner 2012-03-07 16:54:43

+0

我有一個畫廊,並添加這個div攪亂佈局,我想tooltip/div懸停在圖像 – Beginner 2012-03-07 17:00:32

+0

這是一個非常粗略的例子,沒有考慮到任何現有的佈局。您可以嘗試添加'style ='position:absolute;''並相應地放置它(這將需要圖像和div放在父div的'style ='position:relative;'')內。您在原始問題中提到您希望它出現在圖片下方 – solarise 2012-03-08 11:30:08