Reputation: 127
I am trying to track changes on input element below element.
<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;">
This is working when I changed input values manually
$( "input[type='text']" ).change(function() {
alert( "Test" );
});
But when I add readonly
parameter to input value and change input values via Jquery it does not working anymore? How can track changes handled by JQuery?
<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
=============================
Thanks to
Neeraj Amoli
Pranav C Balan
Solution:
Html
<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
JQuery
$("#amount").val("Something").trigger('change');
$("#amount").change(function () {
console.log("Test");
});
Upvotes: 3
Views: 208
Reputation: 1026
$("#amount").on('change',function() {
alert("Test" );
console.log($(this).val());
});
Upvotes: 2