Julia
0
Q:

jquery trigger change event

You can apply any one approach:

$("#Input_Id").change(function(){   // 1st
    // do your code here
    // When your element is already rendered
});


$("#Input_Id").on('change', function(){    // 2nd (A)
    // do your code here
    // It will specifically called on change of your element
});

$("body").on('change', '#Input_Id', function(){    // 2nd (B)
    // do your code here
    // It will filter the element "Input_Id" from the "body" and apply "onChange effect" on it
});
12
$( "#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" ] );
1
$("input").change(function(){
  alert("The text has been changed.");
});
0
$(selector).trigger("change");
-1
var event = new CustomEvent("song_started", { "detail": "Britney is singing baby!"});
document.dispatchEvent(event); //Trigger/Dispatch the event

//Lets listen for event (do this before you dispatch)
document.addEventListener("song_started", function(e) {
    console.log(e.detail);// "Britney is singing baby!"
});
4
$('#textareaID').bind('input propertychange', function() {

      $("#yourBtnID").hide();

      if(this.value.length){
        $("#yourBtnID").show();
      }
});
0
var someEventHander=function(){
	console.log("do something");
}
var handlerCopy=someEventHandler.bind(var1,var2)
//add listener
document.getElementById("someid").addEventListener('click',handlerCopy,true);
//remove listener 
document.getElementById("someid").removeEventListener('click',handlerCopy,true);
0

New to Communities?

Join the community