{"name":"triggerHandler","type":"method","title":".triggerHandler()","deprecated":null,"removed":null,"desc":"Execute all handlers attached to an element for an event.","categories":["events/event-handler-attachment","version/1.2"],"entries":[{"return":"Object","signatures":{"added":"1.2","argument":[{"desc":"A string containing a JavaScript event type, such as click or submit.","name":"eventType","type":"String"},{"desc":"An array of additional parameters to pass along to the event handler.","name":"extraParameters","optional":"true","type":"Array"}]},"examples":{"desc":"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.","code":"\n$( \"#old\" ).click(function() {\n $( \"input\" ).trigger( \"focus\" );\n});\n$( \"#new\" ).click(function() {\n $( \"input\" ).triggerHandler( \"focus\" );\n});\n$( \"input\" ).focus(function() {\n $( \"Focused!\" ).appendTo( \"body\" ).fadeOut( 1000 );\n});\n","html":"\n\n
\n\n\n"},"longdesc":"\n
The .triggerHandler() method behaves similarly to .trigger(), with the following exceptions:
.triggerHandler() method does not cause the default behavior of an event to occur (such as a form submission)..trigger() will operate on all elements matched by the jQuery object, .triggerHandler() only affects the first matched element..triggerHandler() do not bubble up the DOM hierarchy; if they are not handled by the target element directly, they do nothing..triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefinedFor more information on this method, see the discussion for .trigger().