jQuery > Events

Mouse leave event in jQuery

How to attach mouse leave event to a html element in jQuery?

To attach mouse leave event to a element, mouseleave() method can be used.

    <div id="spanMouseDownUp"
        style="background: green; color: White; padding: 10px;">
        Try to bring your mouse

        $("#spanMouseDownUp").mouseleave(function () {
            $(this).html("Mouse left this area");

In the above code when user try to leave the mouse from the “spanMouseDownUp” element then “Mouse left this area” text is written inside it.

 Views: 764 | Post Order: 79

Write for us