trigger change event jquery code example

Example 1: jquery trigger change event

$(selector).trigger("change");

Example 2: jquery onchange input value

$("input").change(function(){
  alert("The text has been changed.");
});

Example 3: 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" ] );

Example 4: jquery on element change

// On element change.
$('mydiv').bind('DOMSubtreeModified', function () {
  console.log('changed');
});