Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
In YUI pre-2.8.0, there is no "mouseleave" event. So, it is pretty awkward to detect whether mouse is moving out of a element with nested children nodes.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="/yui/assets/yui.css?v=3" >
<script src=""</script>
<!-- Browser History Manager source file -->
<style type="text/css" media="screen">
#outer {
height: 500px;
width: 500px;
padding: 100px;
background: gray;
#inner {
height: 200px;
width: 200px;
background: white;
<body class="yui-skin-sam">
<div id="outer">
<div id="inner"></div>
<script type="text/javascript" charset="utf-8">
(function() {
var YUE = YAHOO.util.Event,
YUD = YAHOO.util.Dom;
var container = document.getElementById('outer');
YUE.on(container, 'mouseout', function(e) {
var relatedTarget = YUE.getRelatedTarget(e);
if (!YUD.isAncestor(this, relatedTarget) && (relatedTarget != this)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment