Skip to content

Instantly share code, notes, and snippets.

@johntron
Created February 25, 2014 22:14
Show Gist options
  • Save johntron/9219037 to your computer and use it in GitHub Desktop.
Save johntron/9219037 to your computer and use it in GitHub Desktop.
// jQuery's .trigger() doesn't fire handlers bound with the native .addEventListener() - here's a workaround for modern browsers (IE 9+)
var $el = $('.my-el'),
e;
try {
e = new Event('change');
} catch (unused) {
// Initialize event for IE
e = document.createEvent('Event');
e.initEvent('change', true, true);
}
textBox.get(0).dispatchEvent(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment