1
$(document).ready(function(){
  $("#myTextarea").change(function(){
    alert("text area changed");
  });
  
  //$("#myTextarea").keydown(function(){
    //alert("text area changed");
  //});
});
 
setTimeout(function() {
  $("#myTextarea").val("changed");
  $("#myTextarea").blur();
}, 1000);<!DOCTYPE html>
<body>
  <textarea id="myTextarea" rows="4" cols="20"></textarea>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>I need to know why the above code doesn’t work, in theory, the textarea when modified within the setTimeout, should execute the function code change, but it doesn’t, and I need to know why and how I fix it.
You’re saying it’s time to hit some key?
– novic
Not necessarily @Virgilionovic, if you run the example above you will see that I modify the element by JS, but the page does not understand that it has been modified and the event code
change, is not executed.– FabianoLothor
Fabiano, if I change and leave the box he realizes what he needs, "I think" is not clear what is to do? what is to make this code?
– novic
Exact @Virgilionovic, if you manually type something into the textarea and exit the element, the code I want to be executed will be run, but my problem is that I need to change the element through javascript and I need the event to be called when I change it via javascript.
– FabianoLothor