I want certain code to fire when user change a quantity in a input field. but when user use the little up and down arrow to increase and decrease the quantity quickly. Like press it 5 time to get to 5. I dont want the code to fire 5 times. So I want to set a timer. When on change event is detected it will wait for 1 sec or wait until the on change has stopped. Then grab the latest value.
So is there a way to detect multiple changes in short time span and no nothing. Then if the change happen and no more change happen after x amount to time. do something.
$("#quantity").on('change',function(){
setTimeout(function(){
console.log("fired");
}, 1000);
});
My code is just delaying the fired.
So how can we accomplish this.
Found duplicated question with answer here Jquery change with delay