jQuery - trigger( event, [data] ) Method



The trigger( event, [data] ) method triggers an event on every matched element.

Triggered events aren't limited to browser-based events, you can also trigger custom events registered with bind.


Here is the simple syntax to use this method −

selector.trigger( event, [data] )


Here is the description of all the parameters used by this method −

  • event − An event object or type to trigger.

  • data − This is an optional parameters and represents additional data to pass as arguments (after the event object) to the event handler.


Following is a simple example a simple showing the usage of this method. Here you would trigger a click event on square TWO by clicking on square ONE −

      <title>The jQuery Example</title>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
      <script type="text/javascript" language="javascript">
         $(document).ready(function() {
            $("#div1").click( function () {

            $("#div2").click( function () {
               alert( "Square TWO is clicked");
         div{ margin:10px;padding:12px; border:2px solid #666; width:60px;}
      <span>Click square ONE to see the result:</span>
      <div id="div1" style="background-color:blue;">ONE</div>
      <div id="div2" style="background-color:blue;">TWO</div>

This will produce following result: