trigger

UK[ˈtrɪgə(r)] US[ˈtrɪɡɚ]

n. (gun) trigger; starting device, trigger; triggering other events One thing; [Electronics] Trigger, trigger electrical appliance

vt. Cause, trigger; pull the trigger of...; launch or cause explosion (weapons or explosive ammunition)

Handler

Handler

jquery triggerHandler() method syntax

Function: triggerHandler() method triggers the specified event type of the selected element. However, the browser's default action will not be executed, and event bubbling will not occur. The triggerHandler() method is similar to the trigger() method. The difference is that it does not trigger the default behavior of events (such as form submission), and only affects the first matching element.

Note: The difference with tigger() is that it will not cause the default behavior of events (such as form submission).trigger() will operate all elements matched by the jQuery object, while .triggerHandler( ) only affects the first matching element. Events created by .triggerHandler() do not bubble up the DOM tree; if the target element does not handle them directly, nothing happens. This method returns the return value of the event handling function, not the chainable jQuery object. Additionally, if no handler is triggered, this method returns undefined.

Trigger event: Specifies the event to be triggered by the selected element.

Syntax: $(selector).triggerHandler(event,[param1,param2,...]

##Parameters:

ParameterDescriptionevent Required. Specifies the event to be triggered by the specified element .##[param1,param2,...]

jquery triggerHandler() method example

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("input").select(function(){
    $("input").after("发生 Input select 事件!");
  });
  $("button").click(function(){
    $("input").triggerHandler("select");
  });
});
</script>
</head>
<body>
<input type="text" name="FirstName" value="Hello World" />
<br />
<button>激活 input 域的 select 事件</button>
<p>请注意,与 trigger() 方法不同,triggerHandler() 方法不会引起所发生事件的默认行为(文本不会被选中)。</p>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Optional. Extra parameters to pass to the event handler.