Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :