top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between mouseover() and mouseenter() in jquery?

+1 vote
495 views

Am confused with these functions.Can any one tell me the difference and give some example for each .

posted Aug 1, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It's not true that mouseenter "only occurs when the mouse moves from the parent element to the element". The event occurs when the mouse changes from being outside the element to inside it. It doesn't matter which element the mouse came from. It's true that the mouse will often come from the parent, but not always. Eg, if the parent has no padding or border, then the mouse could enter straight from the grandparent, and mouseenter will still fire. In fact, it can even enter the element from outside the viewport (if the element is right at the edge) and the event still fires.

Example:

$(document).ready(function() {
$("#outer_mouseover").bind
("Mouse Over Mouse Out",function(event){
console.log(event.type," :: ",this.id);})
$("#outer_mouseenter").bind
("Mouse enter Mouse leave",function(event){
console.log(event.type," :: ",this.id);})
 });
answer Aug 4, 2014 by Vrije Mani Upadhyay
Similar Questions
0 votes

I tried the following code.But its not working.

$('#id').mouseover(function(e) {
 setTimeout('alert("Mouse Over Called")', 5000);
}
+1 vote

Tell me the difference for below two functions

$(document).ready(function() {

    alert("Function using Document Ready");

}

vs

$(function() { 
  alert("Normal function");
}
0 votes

Also,tell me what are the types of framework are there ?

0 votes

Please give the example for both.

...