Stop jQuery Mouseleave event when another specific element is input

I need to know how I can stop the mouseleave event when I mouse over another element (link). How to set up a condition that only talks about mouseleave animations if I haven't entered a specific element?

$(activity_link).mouseenter(function() {
    $(this).siblings(".delete_place").animate({ 
                                               "left" : "-28px"
                                              }, 300);     
}).mouseleave(function() {
     $(this).siblings(".delete_place").animate({
                                                "left" : 0
                                               }, 300);
});
+5
source share
2 answers

Using a related event:

$(activity_link).mouseenter(function () {
    $(this).siblings(".delete_place").animate({
        "left": "-28px"
    }, 300);
}).mouseleave(function (e) {
    if (e.relatedTarget != myElem) { //where myElem is a HTML element
        $(this).siblings(".delete_place").animate({
            "left": 0
        }, 300);
    }
});
+4
source

You can stop the event and prevent its bubble / shooting:

...
}).mouseleave(function(event) {
    if(mycondition) {
        $(this).siblings(".delete_place").animate({"left" : 0}, 300);
    } else {
        event.preventDefault();
    }
    ...
0
source

All Articles