Sys.UI.DomEvent addHandler Method

Provides a method to add a DOM event handler to the DOM element that exposes the event. This member is static and can be invoked without creating an instance of the class.

Sys.UI.DomEvent.addHandler(element, eventName, handler, autoRemove);

Term

Definition

element

The element that exposes the event.

eventName

The name of the event.

handler

The client function that is called when the event occurs.

autoRemove

(Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed.

Use the addHandler method to add a DOM event handler to the element that exposes the event. The eventName parameter should not include the "on" prefix. For example, specify "click" instead of "onclick".

Note Note

Do not use the addHandler method for error events. Error events do not have the same signature as DOM events, and their signatures are not consistent. You must bind error events manually.

This method can be accessed through the $addHandler shortcut method.

The following example shows how to associate an event handler with an element by using the addHandler method.

No code example is currently available or this language may not be supported.
Show: