I am pretty new in JavaScript and JQuery and I have the following situation, here the JSFiddle: https://jsfiddle.net/AndreaNobili/eemrb8xo/3/
So, as you can see, in the HTML I have this input field:
<input id="variazioneAnticipo" class="rightAlligned form-control" style="width: 60%" type="number" step="0.01" min="0" value="3" />
Then I have this JQuery code:
$(document).ready(function() {
$("#variazioneAnticipo").change(function() {
var variazioneAnticipo = $("#variazioneAnticipo").val();
alert("CHANGED VALUE, NEW VALUE: " + variazioneAnticipo);
});
});
So, as you can see in the previous JSFiddle, when the user change the value inside the input field the anonymous callback function declared inside change() function and an alert is performed.
Ok, this works.
So the user can change the values in 2 ways:
Using the up and down arrow: when I click the arrow the alert popup is correctly shown.
Changing the value inserting a new number insid the input tag (writing it).
In this second case the anonymous callback function seems to be call only when the user have finisched the insertion of the new number and click out of the input field. I think that this is the standard behavior of the JQuery change() function.
I need that this function is called each time the user insert a new digit inside the input field and not only when it have inserted the entire number and click out of the input field.
Can I obtain this behavior? What can I do?