Javascript Library.
Commands 0 |
---|
Execute a function when the mouse pointer leaves the element. or trigger mouseleave event for an element.
_z(selector).mouseleave(function);
Returns: Object _z(selector)
This method is a shortcut for _z(selector).on( “mouseleave”, function).
To unbind mouseleave event: Unbind mouseleave event
_z(selector).mouseleave();
Returns: Object _z(selector)
_z(selector).un("mouseleave", [function]);
Returns: Object _z(selector)
<button id="button">Show Message & Change Title</button>
<button class="btnCTitle">Change Title</button>
<button class="btnUBEvent">Unbind "Change Title" event</button>
<script>
// bind mouseleave event by element id
_z("#button").mouseleave(function () {
alert("Mouse out!");
});
// bind mouseleave event by element tag - this will bind the event with all elements with "button" tag.
_z("button").mouseleave(function () {
// set title as the element button text
document.title = _z(this).text();
});
// unbind mouseleave event by element class.
_z(".btnUBEvent").click(function () {
_z(".btnCTitle").un("mouseleave");
});
// trigger mouseleave event
_z(".btnCTitle").mouseleave(); // change document title to 'Change Title'
_z("#button").mouseleave(); // alert 'Mouse out!' and change document title to 'Show Message & Change Title'
_z(".btnUBEvent").click(); // change document title to 'Unbind "Change Title" event' and unbind mouseleave event on .btnCTitle button
</script>
Recommended: bind events in .ready() to execute the event when the document is fully loaded.