Jquery Trigger Example - Jquery

How to trigger the specified event using jquery?

Snippet Code

Rate this page :
  [ 0 votes]

The Trigger method is used to trigger the specified event for the selected element. Trigger method executes all the events which matches the content for the given event type. Here the code to trigger the select event of an input element is given below.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").select(function(){ $("#txt").after("Hscripts "); }); $("#btn").click(function(){ $("#txt").trigger("select"); }); }); </script> <input type="text" value="Welcome!" id='txt'></br></br> <input type='button' value='Click to Trigger' id='btn'>


Ask Questions

Ask Question