Difference between mouseover, mouseenter and mousemove events in JavaScript Last Updated : 29 Jul, 2024 Comments Improve Suggest changes 2 Likes 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. Create Quiz Comment G g_ragini Follow 2 Improve G g_ragini Follow 2 Improve Article Tags : JavaScript Web Technologies JavaScript-Misc Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like