JSFiddle - React, Tailwind, and code Playground

by helgatheviking

HTML

<label for="count">Some counter</label><input id="count" data-counter="0" type="number" value="0"/>

JavaScript

let timeout = false;

$('#count').on('change', function() {
  let count = $(this).data('counter') + 1;
  $(this).data('counter', count);
  console.debug('do stuff', count);
});

$('#count').on('input', function() {
  let $input = $(this);
  clearTimeout(timeout);
  timeout = setTimeout(
    function() {
      $input.trigger('change');
    },
    500
  );
});