jquery trigger click code example

Example 1: trigger a click on page load jquery

$("document").ready(function() {
	$("button").trigger('click');
});

Example 2: jquery click function

$( "#target" ).click(function() {
  alert( "Handler for .click() called." );
});

Example 3: trigger button click jquery

$("input").trigger("click");

Example 4: jquery click event

$('#selector').on('click',function(){
    //Your code here
});

Example 5: trigger click jquery

$("selector").click(); //or
$("selector").trigger("click");

Example 6: jquery trigger

$( "#foo" ).on( "click", function() {
  alert( $( this ).text() );
});
$( "#foo" ).trigger( "click" );

$( "#foo" ).on( "custom", function( event, param1, param2 ) {
  alert( param1 + "\n" + param2 );
});
$( "#foo").trigger( "custom", [ "Custom", "Event" ] );

Tags:

Misc Example