Skip to content
Related Articles

Related Articles

jQuery | mousemove() with Examples
  • Last Updated : 13 Feb, 2019

The mousemove() method is an inbuilt method in jQuery which is used when mouse pointer moves over the selected element.
Syntax:

$(selector).mousemove(function)

Parameters: This method accepts single parameter function which is optional. This parameter is used to specify the function to run when the mousemove event is call.

Return Value: This method returns the selected element with the change.

Below method illustrates the mousemove() method in jQuery:

Example:




<!DOCTYPE html>
<html>
    <head>
        <title>The mousemove Method</title>
        <script src=
        </script>
          
        <!-- jQuery code to show the working of this method -->
        <script>
            $(document).ready(function() {
                $("p").mousemove(function() {
                    $("div").css("background-color", "lightgreen");
                });
            });
        </script>
        <style>
            div {
                width: 380px;
                padding: 20px;
                height: 60px;
                border: 2px solid green;
                font-weight: bold;
                font-size: 20px;
            }
        </style>
    </head>
    <body>
        <div>
            <!-- move over this text to see the change -->
            <p>Move over this paragraph.</p>
        </div>
    </body>
</html>


Output:
Before moving mouse over the paragraph:

After moving mouse over the paragraph:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :