Saturday, October 18, 2025
HomeLanguagesJavascriptjQuery mouseenter() Method

jQuery mouseenter() Method

The jQuery mouseenter() method is an inbuilt method which works when mouse pointer moves over the selected element. 

Syntax:

$(selector).mouseenter(function)

Parameters: This method accepts single parameter function which is optional. It is used to specify the function to run when the mouseenter event is called. 

Example 1: This example illustrates the mouseenter() method in jQuery.

HTML




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


Output: 

 

Example 2: In this example, a pop-up will come out when we move the mouse over the paragraph.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>The mouseenter Method</title>
    <script src=
    </script>
  
    <!-- jQuery code to show the working of this method -->
    <script>
        $(document).ready(function () {
            $("p").mouseenter(function () {
                alert("Mouse moved over this paragragh");
            });
        });
    </script>
    <style>
        body {
            width: 300px;
            padding: 40px;
            height: 30px;
            border: 2px solid green;
            font-weight: bold;
            font-size: 20px;
        }
    </style>
</head>
  
<body>
    <!-- move over this paragraph and pop-up will come -->
    <p>Welcome to neveropen!</p>
</body>
  
</html>


Output:

 

Related Articles:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS