I'm trying to implement this answer in my own code:
$(document).ready(function() {
$('#qty').delayKeyup(function() {
var qty = $(this).val();
$(this).val(Math.round(qty / 10) * 10);
}, 1000);
});
(function ($) {
$.fn.delayKeyup = function(callback, ms){
var timer = 0;
$(this).keyup(function(){
clearTimeout (timer);
timer = setTimeout(callback, ms);
});
return $(this);
};
})(jQuery);
but no change in the input value is occurring. If I remove the delayKeyup function the change works OK but obviously not with the delay. What am I missing?