javascript - Add a function to every element that gets clientX -


so i'm doing drag , drop thing. when user grabs element need add event listener dragenter every element. in listener function need , save clientx when mouse moves on element. issue i'm having gets mouse position of first element , keeps same 1 every other element. how can fix this?

code:

if(editor_children[i].nodetype != 3)     {         editor_children[i].addeventlistener("dragenter", function(event){             if(event.target.id !== e.target.id) event.target.classname= event.target.classname + " highlight";             position= event.clientx;             last_over= event.target.id;             console.log("mouse: " + e.clientx + " position: " + position + " last element: " + last_over);         })          editor_children[i].addeventlistener("dragleave", function(event){             event.target.classname= event.target.classname.replace(' highlight', '');         });     } 

please no js libraries.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -