2010-07-21 58 views
1

我是新來的JQuery,我有一個動態的側面菜單(鏈接有類「通道」),當鼠標移過側面菜單中的任何鏈接時,我想要一個div一個圖像和一些文字出現在每個鏈接旁邊,我試過使用很多插件,但直到現在沒有任何工作。幫助與JQuery工具提示

下面是側菜單中的HTML,我想用類「工具提示」每個div來出現一次鼠標在

<a class="channels" href="#"><img src="image path" alt="" /></a> 
<div class="tooltip">this is a tootltip div to the first channel</div> 

    <div class="sep"><!-- --></div> 

<a class="channels" href="#"><img src="image path" alt="" /></a> 
<div class="tooltip">this is a tootltip div to the second channel</div> 

    <div class="sep"><!-- --></div> 

<a class="channels" href="#"><img src="image path" alt="" /></a> 
<div class="tooltip">this is a tootltip div to the third channel</div> 

我真的很感激,如果有人可以幫我解決這個問題。

感謝

回答

1

如果提示包含純文本,那麼你可以考慮使用內置於HTML工具提示...

<a class="channels" href="#" title="this is a tootltip div to the first channel"><img src="image path" alt="" /></a> 

<div class="sep"><!-- --></div> 

<a class="channels" href="#" title="this is a tootltip div to the second channel"<img src="image path" alt="" /></a> 

<div class="sep"><!-- --></div> 

<a class="channels" href="#" title="this is a tootltip div to the third channel"><img src="image path" alt="" /></a> 

如果你需要有某種方式風格的提示,然後讓我知道,我會嘗試爲這種方法提供解決方案。

UPDATE:

爲提示需要包括比簡單的文字更多,這是什麼樣的,你需要的方式...

<div class="tool_container"> 
    <a class="channels" href="#"><img src="path" alt="" /></a> 
    <span class="tooltip">tooltip<img src="path" alt="tooltipImage#1" /></span> 
</div> 
<div class="tool_container"> 
    <a class="channels" href="#"><img src="path" alt="" /></a> 
    <span class="tooltip">another tooltip<img src="path" alt="tooltipImage#2" /></span> 
</div> 

.tool_container 
{ 
    position: relative; 
} 

.tooltip 
{ 
    position absolute; 
    top: -10px; 
    border: 1px solid #808080; 
    background-color: Yellow; 
    display: none; 
} 

$(document).ready(function() { 
    $(".tool_container").hover(
     function(){ 
      $(this).find(".tooltip").show(); 
     }, 
     function(){ 
      $(this).find(".tooltip").hide(); 
     } 
    ); 
} 

注意使用的工具提示,以防止他們從頁面的整個寬度。

實際的標記和CSS將不得不根據你的目的進行調整,但我相信你明白了。

+0

我需要在每一個圖像和文本,所以我想我需要它的樣式,我還添加了一個div來包含每個鏈接和一個工具提示,我認爲這將有所幫助,如果我不是錯了,現在看起來是這樣的:

this is a tooltip
Naruto 2010-07-21 10:46:40

+0

在您的兩個代碼示例,圖像中的鏈接,而不是工具提示 - 你確定了提示有包括圖像? – belugabob 2010-07-21 12:44:14

+0

哦,是的,這是因爲圖像將動態和內容管理,工具提示div將包含另一個圖像和鏈接中的圖像描述... – Naruto 2010-07-21 12:59:00