Difference between mouseover, mouseenter and mousemove events in JavaScript Last Updated : 29 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Events in JavaScript provide a dynamic interface to the webpage. There are wide variety of events such as user clicking, moving the mouse over an element, etc. Events that occur when the mouse interacts with the HTML document falls under the category of MouseEvent property. mouseover: The onmouseover event triggers when the mouse pointer enters an element or any one of its child elements. <element onmouseover="myfunction()">mouseenter: The onmouseenter event is triggered only when the mouse pointer hits the element. <element onmouseenter="myfunction()">mousemove: The onmousemove event is triggered each time the mouse pointer is moved when it is over an element. <element onmousemove="myfunction()">Note: The mousemove event occurs each time the user moves the mouse by one pixel. Example: The following example demonstrates the difference between onmousemove, onmouseenter and onmouseover events used in JavaScript: html <!DOCTYPE html> <html> <head> <title> Difference between mouseover, mouseenter and mousemove events </title> <style> body { text-align: center; } h1 { color: green; } div { margin: 15px 50px 0px 50px; border: 2px solid black; padding: 10px; text-align: center; background-color: #2ec96c; } p { color: white; } h3 { background-color: white; border-radius: 10px; } </style> <script> function over(e) { document.getElementById("sover").innerHTML++; } function enter(e) { document.getElementById("senter").innerHTML++; } function move(e) { document.getElementById("smove").innerHTML++; } </script> </head> <body> <h1>GeeksforGereks</h1> <h4>Mouseover, Mouseenter and Mousemove Example</h4> <div class="over" onmouseover="over(this)"> <h3>Mouseover event triggered: <span id="sover">0</span> times </h3> <p> This event occurs every time when the mouse pointer enters the div element or its child elements (here <h3> or <p>). </p> </div> <div class="enter" onmouseenter="enter(this)"> <h3>Mouseenter event triggered: <span id="senter">0</span> times </h3> <p> This event occurs only when the mouse pointer enters the div element. </p> </div> <div class="move" onmousemove="move(this)"> <h3>Mousemove event triggered: <span id="smove">0</span> times </h3> <p> This event occurs every time the mouse pointer is moved over the div element. </p> </div> </body> </html> Output: Note: Both onmouseenter and onmouseover elements are similar except that the onmouseenter event does not propagate up the document hierarchy. Comment More infoAdvertise with us Next Article What is the difference between position() and offset() in jQuery ? G g_ragini Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Misc Similar Reads Difference between hover() and mouseover() methods in jQuery Before learning the difference between the hover() and mouseover() method of jQuery, let's briefly see both methods. hover() Method: When we hover our mouse cursor to any element, two events happen i.e. mouseenter and mouseleave. mouseenter: When we bring the cursor over the element.mouseleave: When 3 min read How to differentiate mouse âclickâ and âdragâ event using JavaScript ? Working with web elements a user may drag or click an element as per requirement. It is important to distinguish between drag and click events. JavaScript is a high-level, dynamically typed programming language that can be used to distinguish between drag and click events. JavaScript has drag-and-cl 3 min read What is the difference between position() and offset() in jQuery ? Both the jQueryUI method the returns the object which contains integer co-ordinate properties of the top and left positions. The positions of top and left coordinates are returned in pixels. Both functions are applied only on visible elements, not on hidden elements. Example: The example gives top a 2 min read Difference between addEventListener and onclick in JavaScript In JavaScript, both addEventListener() and onclick are used to handle events like clicks, but they function differently. While addEventListener() allows multiple event listeners and better control over event propagation, onclick is limited to a single event handler and gets overwritten.addEventListe 4 min read Difference Between the Click & Mousedown Events The mousedown and the click event in JavaScript occur when the mouse button is pressed. But the click event handles the button press as well as the button release while mousedown only handles the button click. Some of the important differences between them are listed below. Click EventThe click even 3 min read How to call a JavaScript Function from an onmouseover Event ? The onmouseover event in JavaScript is triggered when the mouse pointer moves onto an element, such as a button, image, or text. We will see how to call JavaScript function from an onmouseover event in various ways, like using the onmouseover Attribute and Using Event Listener. Table of Content Usin 2 min read Like