Skip to content

Instantly share code, notes, and snippets.

@jthomas
Created May 23, 2012 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthomas/2775152 to your computer and use it in GitHub Desktop.
Save jthomas/2775152 to your computer and use it in GitHub Desktop.
Creating custom DOM events
// Register for custom events
document.addEventListener("oncustom", function () {
console.log("fired!");
});
// Createcustom DOM events and fire
var evt = document.createEvent("Event");
evt.initEvent("oncustom", true, true);
document.dispatchEvent(evt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment