JavaScript: mouseenter event in JavaScript?
Don't bother with onmouseenter
, as this page states its specific to IE.
...Both onmouseenter and onmouseover fire when the mouse enters the boundary of an element. However, onmouseenter doesn't fire again (does not bubble) if the mouse enters a child element within this first element.
Try this for onmouseover
:
yourObject.onmouseover=function()
{
//SomeJavaScriptCode
};
Check this page for some good info on javascript mouse events.
Navneet Saini
Programming is not my field but it still takes my interest. I am mostly into web Programming(HTML, Javascript , CSS , PHP) stuff. I also have some knowledge about C and Java. Though, still a newbie in all these things. Looking forward to learn more and more here.
Updated on June 26, 2022Comments
-
Navneet Saini about 2 years
Is there a mouse enter event in javascript(only JavaScript, no jQuery to be used, please)?
When I do this, it gives no response.
window.onload = initAll; function initAll(){ if(window.addEventListener){ document.getElementById('container').addEventListener( 'mouseenter', freeze , false); } } function freeze(){ console.log("mouse entered") }
Could someone Please explain me the difference between 'mouseenter' and 'mouseover'? Is 'mouseover' an alternative for 'mouseenter'?
Help Appreciated!
-
Navneet Saini about 11 yearsSo, is there no way to use 'mouseenter' with other browsers?
-
gwin003 about 11 yearsApparently not according to that post. I normally use
onmouseover
anyways. You can useonmouseenter
if you are using jQuery though, according to the first answer in my first link. api.jquery.com/mouseenter/… -
Navneet Saini about 11 yearsBut mouseover keeps on firing again and again? how to prevent that?
-
Rachel Gallen about 11 yearsyou could script a handler for that
-
Rob Johnstone about 11 yearsIf you read what it says at the link you've posted, you'll see that mouseenter has nothing to do with clicks
-
Navneet Saini about 11 years@RachelGallen I am not sure what you are talking about.. Can you please give me some lesson/tutorial link?
-
Rachel Gallen about 11 yearsbasically you code a onmouseout at the same time...to negate the onmouseover
-
Navneet Saini about 11 years@RachelGallen Thanks.. It helped
-
Navneet Saini about 11 years
-
ChrisV over 7 yearsThat page says "Firefox started supporting onmouseenter in version 10 (January 2012) and Chrome started supported it in version 30 (October 2013)"