IsMouseLeaveOrEnter - Fix for mouseover/mouseout


/ Published in: JavaScript
Save to your folder(s)

So the event is fired only once when hovering over child elements


Copy this code and paste it in your HTML
  1. // this function determines whether the event is the equivalent of the microsoft // mouseleave or mouseenter events.
  2. function isMouseLeaveOrEnter(e, handler) {
  3. if (e.type != 'mouseout' && e.type != 'mouseover') return false;
  4. var reltg = e.relatedTarget ? e.relatedTarget :
  5. e.type == 'mouseout' ? e.toElement : e.fromElement;
  6. while (reltg && reltg != handler) reltg = reltg.parentNode;
  7. return (reltg != handler);
  8. }

URL: http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.