Pls Subscribe this channel Subscribe ® Registered teknosys.in
Get link
Facebook
X
Pinterest
Email
Other Apps
Jquery trigger handler
Get link
Facebook
X
Pinterest
Email
Other Apps
-
Returns: Object
.triggerHandler(eventType, extraParameters)
eventType A string containing a JavaScript event type, such as click or submit.
extraParameters An array of additional parameters to pass along to the event handler.
Execute all handlers attached to an element for an event.
The .triggerHandler() method behaves similarly to .trigger(), with the following exceptions:
The .triggerHandler() method does not cause the default behavior of an event to occur (such as a form submission).
While .trigger() will operate on all elements matched by the jQuery object, .triggerHandler() only affects the first matched element.
Events created with .triggerHandler() do not bubble up the DOM hierarchy; if they are not handled by the target element directly, they do nothing.
Instead of returning the jQuery object (to allow chaining), .triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefined
For more information on this method, see the discussion for .trigger().
Example Demo
If you called .triggerHandler() on a focus event - the browser's default focus action would not be triggered, only the event handlers bound to the focus event.
Comments