How do I programmatically trigger an “input” event without jQuery?
The proper way to trigger an event with plain JavaScript, would be to create an Event object, and dispatch it
var event = new Event('input', {
bubbles: true,
cancelable: true,
});
element.dispatchEvent(event);
Or, as a simple one-liner:
element.dispatchEvent(new Event('input', {bubbles:true}));
FIDDLE
This is not supported in IE, for that the old-fashioned way still has to be used
var event = document.createEvent('Event');
event.initEvent('input', true, true);
elem.dispatchEvent(event);
element.dispatchEvent(new Event('input'));