back to Overview

.trigger()

Triggers event handlers registered with on.
Web module only.

Syntax Variants

list.trigger(name)
list.trigger(name, eventObject)

Parameters

name
a single event name to trigger
eventObj (optional)
an object to pass to the event handler, provided the handler does not have custom arguments. Anything you pass here will be directly given to event handlers as event object, so you need to know what they expect.
(return value)
the list

Description

Triggers event handlers registered with on(). Any event that has been previously registered using on() can be invoked with trigger(). Please note that it will not simulate the default behavior on the elements, such as a form submit when you click on a submit button. Event bubbling is supported, thus unless there's an event handler that cancels the event, the event will be triggered on all parent elements.

Example

Simulates a 'click' event on the button.

$('#myButton').trigger('click');

See also..

  • on() registers events that can be triggered.

Comments

comments powered by Disqus

back to Overview

Functions