2010-09-28 132 views
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script> 
</head> 
<body> 
    <div id="popupContact" style="position:absolute;left:100px;top:100px;width:100px;height:50px;background-color:orange;border:1px solid red ;"> 
    </div> 
    <div id="divtoshow" style="display:none;background-color:green; border:1px solid black;width:200px;height:100px;position:absolute;"> 
    dsfdssd <div><a href="#">rahul</a></div> 
    </div> 
</body> 
</html> 
<script type='text/javascript'> 
$(document).ready(function(){ 
    var popup_pos=$('#popupContact').offset(); 
    var timer; 
    $("#popupContact").mouseover(function() { 
     if(timer) { 
      clearTimeout(timer); 
      timer = null 
      } 
     timer = setTimeout(function() { 
      if(!$("#VersionSelectField").is(':hidden')){ 
       $("#divtoshow").css('position',"absolute"); 
       $("#divtoshow").css('top',popup_pos.top-20);  
       $("#divtoshow").css('left',popup_pos.left-20); 
       $("#divtoshow").show(); 
       $("#popupContact").hide(); 
      } 

     }, 1000); 

    }); 

    $("#divtoshow").mouseleave(function() { 
      if(timer) { 
       clearTimeout(timer); 
       timer = null 
       } 
      timer = setTimeout(function() { 
       $("#divtoshow").hide(); 
       $("#popupContact").show(); 

      }, 500); 
    }); 
}); 
</script> 

您好我有下面的代碼,然後時也正在顯示我的鼠標在popupcontact DIV,突然鼠標移出div的,divtoshow格,但我不希望出現這種情況,請幫助... ...jQuery的鼠標移出和鼠標離開的問題

問:如何不顯示div div,而我突然彈出popupcontact div嗎?
我想在鼠標離開中的setTimeout()延遲

+2

而你的問題是? – 2010-09-28 12:02:13

+0

如何不顯示div div div,而我突然鼠標popupcontact div? – XMen 2010-09-28 12:07:34

回答

1

什麼

$("#popupContact").mouseout(function() { 
    $("#divtoshow").hide(); 
    $("#popupContact").show(); 
}); 

+0

不,它也顯示divt div – XMen 2010-09-28 12:35:15

+0

哦,我想我明白你想要什麼(timer); timer = null; } }); – Shikiryu 2010-09-28 12:50:49

+0

感謝Chouchenos它的工作。 – XMen 2010-09-28 13:07:02

0

變500爲0()

+0

但我想延遲:( – XMen 2010-09-28 12:09:27

+0

你不是說你想要div快速隱藏嗎?爲什麼你需要延遲? – Stewie 2010-09-28 12:10:48

+0

我需要的是顯示信息 – XMen 2010-09-28 12:12:24

相關問題