How to use triggerHandler() Method Event in JQuery

This article describe about triggerHandler() Method Event in jQuery.
  • 2662

triggerHandler() Method Event in jQuery

It is specified triggers event types for selected element.

It is similar to the trigger() method. Except that it does not trigger the default behavior of an event, it is only effects the first matched element.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("input").select(function () {

            $("input").after(" Input select event occured!");

        });

        $("button").click(function () {

            $("input").triggerHandler("select");

        });

    });

</script>

</head>

<body>

<input type="text" name="FirstName" value="Hello" />

<br />

<button>Activate the select event of the input field.</button>

<p>Note that, unlike the trigger() method, the triggerHandler() method does not cause the default behavior of the event to occur.</p>

</body>

</html>

 

Output

 

trigger handler method pic4.jpg

 

Trigger an Event

Define an event to trigger for the selected element.

 

Syntax

 

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

 

Parameter Description
event Required. It is define the event to trigger for selected element.
[param1, param2.....] Optional. It is define the additional parameter for the event handler

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.