Open In App
Related Articles

How to run a code on mouseenter event in jQuery ?

Improve Article
Save Article
Like Article

In this article, we will see how to run the code when the mouse enters into the specific area using jQuery. To run the code on a mouse enter a specific area, mouseenter() method is used. The mouseenter() method works when the mouse pointer moves over the selected element.



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



<!DOCTYPE html>
        How to run a code on mouseenter
        event in jQuery?
    <script src=
        $(document).ready(function () {
            $(".main").mouseenter(function () {
                    background: "green",
                    color: "white"
        body {
            text-align: center;
        .main {
            width: 300px;
            height: 200px;
            border: 2px solid black;
    <div class="main">
            How to run a code on mouseenter
            event in jQuery?


Last Updated : 25 Mar, 2021
Like Article
Save Article
Similar Reads
Related Tutorials