UnderZ

Javascript Library.

Trigger an event on an element.

Execute an event.


Trigger event

_z(selector).trigger("click");

Returns: Object _z(selector)

To bind an event: Bind event

To unbind an event: Unbind event


Examples

<button id="button">Change Title</button>
<button id="buttonBind">Bind event</button>
<button id="buttonUnbind">Unbind event</button>

<script>
// bind click event by element id
_z("#buttonBind").on("click", function () { 

	// bind click event.
	_z("#button").on("click", function () { 
		// set title as the element value
		document.title = _z(this).text();
	});
	
});


// unbind click event by element id
_z("#buttonUnbind").on("click", function () { 

	// unbind click event.
	_z("#button").un("click");
	
});

// bind click event by element tag name
_z("button").on("click", function () { 
	// set title as the element value
	document.title = _z(this).text();
});


// trigger click event
_z("#button").trigger("click"); // Trigger click event
</script>