title: How to detect when the value of an input changes dynamically with JS / Jquery
body: <p>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:</p>
  
  <p>Lets say I have an input </p>
  
  <pre><code>&lt;input id="testInput" value="Type Here" /&gt;
  </code></pre>
  
  <p>And if the value changes by typing on it I want to alert "changed"</p>
  
  <pre><code>$('#testInput').on('input', function(){
      alert("changed");
  });
  </code></pre>
  
  <p>This works, but if the value changed dynamically from another script, I can't trigger the alert:</p>
  
  <pre><code>$('#testInput').val("Dynamic Value"); //This doesn't show the alert
  </code></pre>
  
  <p>I want to be able to detect if the value changed at all, either by typing, pasting, or dynamically from a script or action.</p>
  
  <p><code>.val()</code> Is beeing executed in many different places, so changing <code>.val()</code> all over the code for something else like <code>.val().trigger("change")</code> is not an option.</p>
  
  <p>Here is a jsfiddle with a better example:</p>
  
  <p><a href="https://jsfiddle.net/xpvt214o/486146/" rel="nofollow noreferrer">https://jsfiddle.net/xpvt214o/486146/</a> </p>