Skip to content Skip to sidebar Skip to footer

How To Implement Debounce Fn Into Jquery Keyup Event?

A calculation is based on user input, and criteria is to use keyup rather than change or blur. The problem is that the code fires on every keystroke, and I need it to delay and fir

Solution 1:

Use it like this:-

$('input').keyup(debounce(function(){
    var $this=$(this);
    //alert( $this.val() );var n1 = $this.val();
    var n2 = $('#n2').val();
    var n3 = $('#n3').val();
    var calc = n1 * n2 * n3;
    alert(calc);
},500));

Fiddle

Post a Comment for "How To Implement Debounce Fn Into Jquery Keyup Event?"