myEventTarget.dispatchEvent( evt ) in DOM Level 2 Events
Dispatches an event to the invoking object.
Arguments
name | type | description |
---|---|---|
evt | Event | A valid event object |
- Return Type
- Boolean
Description
This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.
Before dispatching an event, it must first be created (see createEvent(...)) with and initialized (see initEvent(...)).
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change',true,true);
document.getElementById('foo').dispatchEvent( evt );