jeudi 7 juillet 2016

Is there any event executed when the value of textarea changes?

Here is a simplified snippet of my code:

$("#textarea_id").on('input propertychange', function(e){
	alert('the value of textarea changed');
});

$("#bold").on('click', function(e){
	$("#textarea_id").val('bold');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id = "textarea_id"></textarea>
<br>
<button id = "bold">
B
</button>

I want to see that alert when the value of that textarea changes (in any way). As you see it just runs when we write something into that textarea, but not when we click on that button (while it should be, because when we click on that button, the value of that textarea changes). How can I make it sensitive for every kind of changes?

Aucun commentaire:

Enregistrer un commentaire