Reputation: 7877
I have a textbox whose text is expected to be changed from the jquery code.
It is not firing when the value assinged from jquery code however it is firing when I change the text by key press.
Below is HTML and JQuery which i am using
<input type="text" id="txtProjectName"/>
$("#txtProjectName").on('change keyup paste mouseup', function () {
alert('Changed');
});
What modifications would require here? please assist.
Upvotes: 3
Views: 1260
Reputation: 133403
It is not firing when the value assinged from jquery code
Programmatically changing the value of an input doesn't fire its change event. You'll have to do that yourself using .trigger()
You need need to trigger change event when changing value from code
$("#txtProjectName").val('Whatever').trigger('change');
Upvotes: 5