Stop jQuery Mouseleave Event When Entering Another Specific Element

javascript, jquery

Solution

Use of event relatedTarget:

$(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);
    }
});

Problem

I need to know how I can stop my mouseleave event from occuring when I slide my mouse over to a different element (link). How can I setup a condition that says to only do the mouseleave animation if I have not 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); }); ```

Original source