Question: When I hover over a div (assume it has id=div-CON), I have another div, positioned absolute, that pops up and follows the mouse while I am within div-CON. When the mouse leaves div-CON, the floating div disappears.

Now, there are instances where if the browser is slow or lagging, the floating div does not update its position quick enough such that the mouse enters the floating div for an instant then leaves it. In this instant, the mouse leaves div-CON and enters again so the floating div essentially blinks.

With regards to this, I was wondering if there was a way to ignore or cancel events so that in this case, when the mouse enters the floating div, the mouseleave event is not triggered on div-CON.

Heres a jsFiddle: <http://jsfiddle.net/vuxcR/>

Answer: 
You can set a timeout (delay) when the cursor leaves the floating element. When it's hovered again, the time out clears.

See **[this answer](https://stackoverflow.com/questions/7786686/show-an-alert-when-mouse-is-on-a-div-for-2-seconds/7786706#7786706)** for the concept.

```
var timer;
function addFollower($element, event_mouseEnter, event_mouseMove, event_mouseLeave){
    clearTimeout(timer);
    $element.mouseleave(function(){
        timer = setTimeout(event_mouseLeave, 300); //Delay of 300ms
    })
    $element.mouseenter(function(){
        clearTimeout(timer); //Clear any delay

        event_mouseEnter();
    });
    $element.mousemove(event_mouseMove)
}
addFollower($("#div-CON"),
    function(ev){
        //Mouse-enter
    },
    function(ev){
        //Mouse move
    },
    function(){
        //Mouse-leave
    }
);

```
You could track the exact position of mouse and check if its with the div-CON rectangle. Do not trigger the cancel action till the mouse leaves this rectangle.