Skip to content

Instantly share code, notes, and snippets.

@acmcelwee
Created May 22, 2013 04:43
Show Gist options
  • Save acmcelwee/5625294 to your computer and use it in GitHub Desktop.
Save acmcelwee/5625294 to your computer and use it in GitHub Desktop.
Event trigger (this works with document.addEventListener)
function triggerEvent(element, eventType) {
var e;
if (document.createEventObject) {
//ie
e = document.createEventObject();
element.fireEvent(eventType, e);
} else {
//others
e = document.createEvent('HTMLEvents');
e.initEvent(eventType, true, true);
element.dispatchEvent(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment