Sajid Mohammed
Sajid Mohammed

@sajid_curious

12 Tweets 11 reads Jul 05, 2022
✨ Difference between mouseenter and mouseover event in Javascript ✨
A thread 🧡 πŸ‘‡πŸ‘‡πŸ‘‡
➑️ mouseenter event:
β†’ The event occurs when the pointer is moved onto an element.
➑️ mouseover event:
β†’ The event occurs when the pointer is moved onto an element, or onto one of its children.
Let's understand it clearly with an example πŸ‘‡πŸ‘‡πŸ‘‡
➑️ HTML code
β†’ I made two divs with id's, one is mouseenter and other is mouseover.
β†’ Inside each div I opened a <p>, and two other divs, which are given the id's too.
➑️ CSS code
β†’ I centered the div with flexbox for the better view.
β†’ Style the divs and their child elements using below code or you can follow your own code.
➑️ Javascript code
β†’ Assign a variable and get the div using DOM.
β†’ Add event listener to it
β†’ In the event listener we need to pass two parameters.
parameter 1 : event name
parameter 2 : function name.
β†’ Define the function mentioned in the event listener.
➑️ Observation
β†’ Inside the functions i stated to change color and console the respective methods on triggering the event.
β†’ mouseenter event triggers only once after entering the element or child.
β†’ mouseover event triggers everytime when it enters the element and child.
➑️ Final output
β†’ Observe the console area while entering the elements to observe the difference.
➑️ Read this thread for onclick event πŸ‘‡
➑️ Read this thread for mouseenter event πŸ‘‡
➑️ Read this thread for mouseleave event πŸ‘‡
➑️ Read this thread for mouseover event πŸ‘‡
We'll discuss remaining events in the upcoming series of threads
If you found it useful
Consider
Like ❀️
Retweet the first tweet ⚑
Follow @sajid_curious for more contentπŸ“˜on
HTML 🦴
CSS πŸ‘•
JAVASCRIPT 🧠
comment below πŸ‘‡

Loading suggestions...