English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery trigger() method

jQuery Events

The jQuery trigger() method triggers the specified event on the selected element and the default behavior of the event (such as form submission).

To trigger the event handler without triggering the default behavior, please usetriggerHandler()Method.

Syntax:

$(selector).trigger(event, param1, param2, ...)

Example

Trigger the select event of the <input> field:

$("button").click(function(){
  $("input").trigger("select");
});
Test and see‹/›

Trigger the click event of the <div> element:

$("button").click(function(){
  $("div").trigger("click");
});
Test and see‹/›

Show the difference between the trigger() method and the triggerHandler() method:

$("#btn1").click(function(){
  $("input").trigger("select");
});
$("#btn2").click(function(){
  $("input").triggerHandler("select");
});
Test and see‹/›

Parameter Value

ParameterDescription
eventA string containing JavaScript event types, such as click or Submit
param1,param2,...(Optional) Other parameters passed to the event handler

jQuery Events