Trigger Change event when the Input value changed programmatically?

html, javascript, jquery

Solution

You are using jQuery, right? Separate JavaScript from HTML.

You can use trigger or triggerHandler.

var $myInput = $('#changeProgramatic').on('change', ChangeValue);

var anotherFunction = function() {
  $myInput.val('Another value');
  $myInput.trigger('change');
};

Problem

I have an Input in my form. ``` <input type="text" id="changeProgramatic" onchange="return ChangeValue(this);"/> ``` If I change the value in this textBox (changeProgramatic) using another JavaScript function it won't trigger the change Event.(Note: I'm passing 'this' into the method)

Original source

Related problems