Barry M. Wong

UI Engineer + Designer

Blog

This one was easy

July 13, 2013 at 9:18 am | code

/**
 * We have a textbox where we get the info with the following code:
 *
 *   var tb = $(".textbox");
 *
 * We want to get the text of that box, but only 600 ms after the person stops
 * typing in that box. How would you implement it?
 */
 
var timer;
var tb = $(".textbox");

tb.on('keyup', function() {
  var that = this;
  clearTimeout(timer);
  timer = setTimeout(function() {
    $('.textboxContents').html(that.value);
  }, 600);
});