2012-10-21 135 views
0

感謝您的閱讀。在div之間移動時使div保持打開狀態(使用jQuery)

目前,以下是我的代碼:

<script> 
$(document).ready(function(){ 
    $('.withdraw_money').hover(function(){ 
     if ($("#withdraw_money_div").is(":hidden")){ 
      $("#withdraw_money_div").slideDown("slow") 
     }else{ 
      $("#withdraw_money_div").hide() 
     } 
    }); 
}); 
</script> 

好。因此,當其他div(.withdraw_money)懸停時,我可以將div(#withdraw_money_div)滑下。但我現在的問題是,如何將div移到#withdraw_money_div時繼續保持懸停狀態?

我似乎無法找到辦法做到這一點。任何幫助表示讚賞

回答

1
在你的HTML

#withdraw_money_div'.withdraw_money',使得一個孩子,因此,你仍然會在.withdraw_money懸停事件

還..

$(document).ready(function(){ 
$('.withdraw_money').hover(function(){ 
    if ($("#withdraw_money_div").is(":hidden")){ 
     $("#withdraw_money_div").slideDown("slow") 
    }else{       // why is this here? 
    $("#withdraw_money_div").hide() //if div isn't hidden(shown) you're hiding it!! 
    } 
    }); 
}); 

我建議.mouseOver.hover 2功能,它將覆蓋鼠標懸停和一個函數,當你懸停在div - 我認爲這是你通過其他語句

0

工作演示試試這個http://jsfiddle.net/YuBNT/

希望它適合事業:)

代碼

$(document).ready(function() { 
     $("#withdraw_money_div").hide(); 
     $('.withdraw_money').hover(function() { 
      $("#withdraw_money_div").slideDown("slow") 


     }, function() { 
      $("#withdraw_money_div").slideUp("slow") 

     }); 
    });​ 
+0

我假設他的HTML was't寫有 「#withdraw_money_div」 作爲'一個孩子.withdraw_money'就像它是在你的小提琴 - 否則他的代碼將已經工作 –

+0

沒關係,我重新讀他的代碼 –

+0

@ScottSelby感謝評論 - 好吧,希望Html將盡快由OP給出,但dmoe將giv他/她更好的主意,':)' –

相關問題