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