Accepted answer

You need to use MutationObserver window class to observe an input's change triggered by JS.

Keep in mind that simply setting input's node value property, for instance, won't trigger MutationObserver. You have to invoke setAttribute(value, "value") to get the change picked up by MutationObserver.

Here's a working example I've made:

Of course, this is a vanilla JS solution. If you don't care about vanilla and using jQuery is a desirability, you can attempt to use this jQuery-fied answer: Detect all changes to a <input type="text"> (immediately) using JQuery

Though, I can't guarantee it'll work. Have not tested.


you can execute functions with the oninput="" attribute in an input element.

<input type="text" oninput="myFunction()">

In JS, you can also use:

$("myobject").oninput = function(){myScript};

or you are better with this one:

$("myobject").addEventListener("input", myScript);

Related Query