$(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 does not work, theoretically, textarea
when modified within setTimeout
, should run the change
function code, but it does not execute and I need to know why and how I solve it .