Skip to content
Related Articles

Related Articles

How to run a code on mouseenter event in jQuery ?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 25 Mar, 2021

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?


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!