Easy Tutorial
❮ Ajax Serialize Misc Parsejson ❯

jQuery triggerHandler() Method

jQuery Event Methods

Example

Trigger the select event on an <input> element:

$("button").click(function(){
    $("input").triggerHandler("select");
});

Definition and Usage

The triggerHandler() method triggers the specified event for the selected elements.

This method returns the return value of the event handler, rather than the jQuery object. Additionally, if no handler is triggered, this method returns undefined.

This method is similar to the trigger() method, except that trigger() also triggers the default behavior of the event (such as form submission).

Differences compared to the trigger() method:

Example

Comparison between triggerHandler() and .trigger():

$( "#old" ).click(function() {
  $( "input" ).trigger( "focus" );
});
$( "#new" ).click(function() {
  $( "input" ).triggerHandler( "focus" );
});
$( "input" ).focus(function() {
  $( "<span>Focused!</span>" ).appendTo( "body" ).fadeOut( 1000 );
});

Syntax

Parameter Description
event Required. Specifies the event to trigger on the specified element.
param1, param2, ... Optional. Additional parameters to pass to the event handler. <br>Extra parameters are particularly useful for custom events.

More Examples

Passing Additional Parameters to Custom Events

Differences Between trigger() and triggerHandler()


jQuery Event Methods

❮ Ajax Serialize Misc Parsejson ❯