html - Strange thing with onmousemove javascript -


enter image description herehi guys:)if pass on div in example mouse's pointer function print in console 2 times,this menans onmousemove event triggered 2 times.i have printed coordinates of mouse's pointer , how can see in image below,i don't move verticallylly horizontally.how possible onmousemove event triggered considered div 1 pixel width?how possible onmousemove event triggered 2 times considered div 1 pixel width?

  <div id="div1">  </div>  #div1{   height:200px;   width:1px;   background:red;  }   document.getelementbyid("div1").onmousemove= function(){                console.log("in mousemove function");               console.log(event.clientx);               console.log(event.clienty);               }; 

you bind onmousemove called every time mouse moved on element. when hover div move mouse down resolving in additional calls handler.

it more clear if add more width div.

what wants onmouseenter called once when enter div:

document.getelementbyid('div1').addeventlistener('mouseenter', function() {   console.log('mouse entered div'); }); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -