Created
June 6, 2011 14:26
-
-
Save lxcodes/1010361 to your computer and use it in GitHub Desktop.
JavaScript TriggerEvent
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
Element.prototype.triggerEvent = function(eventName) | |
{ | |
if (document.createEvent) | |
{ | |
var evt = document.createEvent('HTMLEvents'); | |
evt.initEvent(eventName, true, true); | |
return this.dispatchEvent(evt); | |
} | |
if (this.fireEvent) | |
return this.fireEvent('on' + eventName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment