I am able to detect if an input changes value while typing, pasting, etc, But if the value changed dynamically from another script I am unable to detect it:
Lets say I have an input
<input id="testInput" value="Type Here" />
And if the value changes by typing on it I want to alert "changed"
$('#testInput').on('input', function(){
alert("changed");
});
This works, but if the value changed dynamically from another script, I can't trigger the alert:
$('#testInput').val("Dynamic Value"); //This doesn't show the alert
I want to be able to detect if the value changed at all, either by typing, pasting, or dynamically from a script or action.
.val()
Is beeing executed in many different places, so changing .val()
all over the code for something else like .val().trigger("change")
is not an option.
Here is a jsfiddle with a better example: