2011-02-08 185 views
2

嗨我想要滑出一個元素,當鼠標移過去然後滑回去並隱藏鼠標熄滅時..我有這個代碼,但我有問題時鼠標離開元素第一個mouseenter功能完成.. .entry_extend div保持可見。我試圖懸停功能,但是是同樣的問題..請幫助..謝謝。jQuery懸停問題

jQuery("document").ready(function(){ 
        jQuery(".fire").mouseenter(function(){ 
         jQuery(this).children('.entry_extend').stop(true, false).show('slide',null,500,null); 

        }); 
        jQuery(".fire").mouseleave(function(){ 
         jQuery(this).children('.entry_extend').stop(true, false).hide('slide',null,500,null); 
        }); 

       }); 


<div id="craft" class="fire"> 
     <div class="entry_main"> 
      <a href="" title=""> 
      <img src="" alt="" /> 
      </a> 
     </div> 
     <div id="entry_ex_craft" class="entry_extend"> 
      <a href="" title="">original shisha pipe collection</a> 
    </div> 
</div> 

請幫助:)

+0

你可以發佈你正在測試這個標記嗎? – Loktar 2011-02-08 21:38:01

+0

你的html會真的有幫助 – heymrcarter 2011-02-08 21:42:29

回答

1

您正在嘗試實施 「懸停」。這工作:

jQuery(".fire").hover(
    function(){jQuery('.entry_extend', this).stop(true, true).show(500);} 
    , 
    function(){jQuery('.entry_extend', this).stop(true, true).hide(500);} 
); 

你要知道,這不是一個好主意,有你,你徘徊在DIV內滑動進出DIV,因爲隱藏DIV改變包含它的DIV的邊界。正因爲如此,最終可能會出現一些「顫抖」的活動。

0

嘗試結合鼠標懸停+的mouseenter和鼠標移開+鼠標離開使用綁定..看到here

jQuery("document").ready(function(){ 
        jQuery(".fire").bind('mouseover mousenter',function(){ 
         jQuery(this).children('.entry_extend').stop(true, false).show('slide',null,500,null); 

        }); 
        jQuery(".fire").bind('mouseout mouseleave',function(){ 
         jQuery(this).children('.entry_extend').stop(true, false).hide('slide',null,500,null); 
        }); 

       });