When the user delete the value in input using the backspace the function work correctly but if he delete the value and set a new number like 1 the new value is deleted and set again to zero.
<input type="text" id="txtField" value="0" ></input>
$(document).ready(function() {
$("#txtField").keyup(function() {
var v = $(this).val();
console.log(v)
if (v == "") {
console.log(v)
setTimeout(function() {
$("#txtField").val(0);
}, 1000);
}
});
});
I don't know what is the problem in my code any help please?
jsFiddle: http://jsfiddle.net/2shadgtw/2/