Last active
April 11, 2016 08:30
-
-
Save JacobWay/ad047e4706a09cf07599096e9879eef1 to your computer and use it in GitHub Desktop.
The older approach to creating events uses APIs inspired by JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create event | |
var evt = document.createEvent("Event"); | |
// initializing the event | |
evt.initEvent("anyName", true, true); | |
// add event handler | |
document.addEventListener("anyName", function(e){ | |
// your handler logic | |
console.log("e.target: ", e.target); | |
}, false); | |
// dispatch the event | |
document.dispatchEvent(evt); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment