views:

35

answers:

2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<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>

hi i have following code , when i mouse over the popupcontact div and suddenly mouse out the div then also the divtoshow div is being shown but i dont want that please help ......

Q:how to not to show divtoshow div while is i suddenly mouseout the popupcontact div ?
i want the delay

A: 

change 500 to 0 in setTimeOut() in mouseleave()

Stewie
but i want the delay :(
Rahul Mehta
didn't you say that you want the div to hide quickly ? Why do you need the delay ?
Stewie
i need that for showing the information
Rahul Mehta
to feel the user that something is opening ..
Rahul Mehta
yes i want to hide the div quickly..
Rahul Mehta
What ? Don't worry about the feel. Opening quick will feel much better to the user.
Stewie
+1  A: 

What about

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

?

Chouchenos
no it is also showing the divtoshow div
Rahul Mehta
Oh, I think I see what you want. Try adding $("#popupContact").mouseleave(function() { if(timer) { clearTimeout(timer); timer = null; } });
Chouchenos
thanks Chouchenos it worked
Rahul Mehta