jQuery > Events

Mouse move event in jQuery

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


To attach mouse move event to a html element, mousemove() method can be used.

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

    <script>
        $("#spanMouseDownUp").mousemove(function () {
            $(this).html("You have started moving");
        });
    </script>

In the above code when user move mouse over “spanMouseDownUp” element then “You have started moving” text will be written inside it.

 Views: 1140 | Post Order: 80



Write for us