The mouseenter() Event executes when a mouse pointer enters an element.
<html> <head> <title> My First Programme </title> </head> <body> <h1> JQuery </h1> <p class = "para1"> First Paragraph </p> <img src = "/myImage.png" alt = "Bring the mouse pointer here"/> <script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script> <script> $('img').mouseenter( function() { $('p').text("Mouse pointer is in the image") }); </script> </body> </html>
So, if you look at the above code, we have a <p> element,
<p class = "para1"> First Paragraph </p>
And we have an image,
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
Now, if we take a look at the JQuery statement,
$('img').mouseenter( function() { $('p').text("Mouse pointer is in the image") });
At first we locate the image,
$('img')
Then we use the mouseenter() event,
$('img').mouseenter(...)
And put the function inside mouseenter() event to change the contents of <p> element.
$('img').mouseenter( function() { $('p').text("Mouse pointer is in the image") });
And the function,
function() { $('p').text("Mouse pointer is in the image") }
Changes the content of <p> with the text,
'Mouse pointer is in the image'
When the mouse pointer enters the Image.