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
here
    </div>

    <script>
        $("#spanMouseDownUp").mouseleave(function () {
            $(this).html("Mouse left this area");
        });
    </script>

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: 4740 | Post Order: 79



Write for us






Hosting Recommendations