Skip to main content

enode.on()

enode.on() is used to add an event listener to the associated HTML element of the current enode.

Since this method is built on top of EventTarget.addEventListener() in Web APIs, their usage is basically the same.

Syntax

JavaScript
enode.on(eventType: String, eventCallback: Function, options: Object)

Parameters

eventType

  • A case-sensitive string which specifies the type of event.

eventCallback

  • The event handler function to add to the event target.

options (optional)

  • An object that specifies characteristics about the event listener. For available options, read here.

Return value

The current enode, ready for the chaining method calls.

Examples

JavaScript
var button = new Binh.ElementNode(document.createElement('button'));

button.on('click', function(event) {
// hanle event
alert('clicked');
});