Home >>jQuery Tutorial >jQuery triggerHandler() Method

jQuery triggerHandler() Method

jQuery triggerHandler() Method

jQuery triggerHandler() method in jQuery is used to triggers the specified event for the selected element.

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

Parameter Values

Parameter Description
event It is a required parameter and used to specifies the event to trigger for the specified element
param1,param2,... It is an optional parameter and used to attach an additional parameters to pass on to the event handler.
Here is an Example of jQuery triggerHandler() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").select(function(){
$("input").after("Triggered select event!");
});
$(".btn1").click(function(){
$("input").triggerHandler("select");
});
});
</script>
</head>
<body>
<input type="text" value="Hello Phptpoint"><br><br>
<button class="btn1">click me to Trigger the select event</button>
</body>
</html>

Output: