<pclass="desc"><strong>Description: </strong>Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element.</p>
<p>This method is a shortcut for <code>.bind('mouseleave', handler)</code> in the first variation, and <code>.trigger('mouseleave')</code> in the second.</p>
<p>The <code>mouseleave</code> JavaScript event is proprietary to Internet Explorer. Because of the event's general utility, jQuery simulates this event so that it can be used regardless of browser. This event is sent to an element when the mouse pointer leaves the element. Any HTML element can receive this event.</p>
<p>The event handler can be bound to any element:</p>
<pre>$('#outer').mouseleave(function() {
$('#log').append('<div>Handler for .mouseleave() called.</div>');
});</pre>
<p>Now when the mouse pointer moves out of the <spanclass="output">Outer</span><code><div></code>, the message is appended to <code><div id="log"></code>. We can also trigger the event when another element is clicked:</p>
<pre>$('#other').click(function() {
$('#outer').mouseleave();
});</pre>
<p>After this code executes, clicks on <spanclass="output">Trigger the handler</span> will also append the message.</p>
<p>The <code>mouseleave</code> event differs from <code>mouseout</code> in the way it handles event bubbling. If <code>mouseout</code> were used in this example, then when the mouse pointer moved out of the <spanclass="output">Inner</span> element, the handler would be triggered. This is usually undesirable behavior. The <code>mouseleave</code> event, on the other hand, only triggers its handler when the mouse leaves the element it is bound to, not a descendant. So in this example, the handler is triggered when the mouse leaves the <spanclass="output">Outer</span> element, but not the <spanclass="output">Inner</span> element.</p>
<h4><spanclass="desc">Show number of times mouseout and mouseleave events are triggered.
mouseout fires when the pointer moves out of child element as well, while mouseleave fires only when the pointer moves out of the bound element.</span></h4>
<div class="out overout"><p>move your mouse</p><div class="in overout"><p>move your mouse</p><p>0</p></div><p>0</p></div>
<div class="out enterleave"><p>move your mouse</p><div class="in enterleave"><p>move your mouse</p><p>0</p></div><p>0</p></div>